Sha256: 4f733ce95dc6bb6ad8e4cc82eaa7c6a8f2baeef75123489f5d6ddc2635f2ebdb

Contents?: true

Size: 807 Bytes

Versions: 16

Compression:

Stored size: 807 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 %>)
<% end -%>
<% @type.file_attributes.each do |attribute| -%>
  mount_uploader :<%= attribute.name %>, CMS::Uploader
<% end -%>

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
honey-cms-0.3.8 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.7 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.5 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.4 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.3 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.2 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.1 lib/generators/cms/templates/type_model.rb
honey-cms-0.3.0 lib/generators/cms/templates/type_model.rb
honey-cms-0.2.4 lib/generators/cms/templates/type_model.rb
honey-cms-0.2.3 lib/generators/cms/templates/type_model.rb
honey-cms-0.2.2 lib/generators/cms/templates/type_model.rb
honey-cms-0.2.1 lib/generators/cms/templates/type_model.rb
honey-cms-0.2.0 lib/generators/cms/templates/type_model.rb
honey-cms-0.1.2 lib/generators/cms/templates/type_model.rb
honey-cms-0.1.1 lib/generators/cms/templates/type_model.rb
honey-cms-0.1.0 lib/generators/cms/templates/type_model.rb