Sha256: 3c1cf4c1752022b544dbeeef1eea7d20602bff37439dfb68ff80beba009c93b7

Contents?: true

Size: 833 Bytes

Versions: 5

Compression:

Stored size: 833 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 -%>

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
honey-cms-0.3.13 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.12 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.11 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.10 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.9 lib/generators/cms/templates/type_model.rb