Sha256: a19d4c055a44ca28383e7347df2fea7c55943852e98495841ba306584ac77bbf

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 Bytes

Contents

class CMS::<%= @name %> < ActiveRecord::Base
  self.table_name = '<%= @name.collection %>'
<% @type.attributes.select {|attr| attr.reference? }.each do |attribute| -%>
  belongs_to :<%= attribute.name %>, class_name: 'CMS::<%= attribute.reference_to %>'
<% end -%>
<% if @type.references.any? -%>
<% @type.references.each do |type| -%>
  has_many :<%= type.model_name.collection %>, class_name: 'CMS::<%= type %>'
<% end -%>
<% end -%>
  attr_accessible <%= @type.accessible_attributes.map {|a| ":#{a.field_name}" }.sort.join(', ') %>
<% if @type.orderable? -%>
  include CMS::Orderable
  orderable(:<%= @type.order_attribute.name %><%= @type.order_options %>)
<% end -%>
<% @type.file_attributes.each do |attribute| -%>
  mount_uploader :<%= attribute.name %>, CMS::Uploader
<% end -%>

  belongs_to :author, model_name: 'User'

  def self.name
    '<%= @name %>'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
honey-cms-0.4.5 lib/generators/cms/templates/type_model.rb
honey-cms-0.4.2 lib/generators/cms/templates/type_model.rb
honey-cms-0.4.1 lib/generators/cms/templates/type_model.rb
honey-cms-0.4.0 lib/generators/cms/templates/type_model.rb