Sha256: d11bf726b5f8783649dd71298c8a61df2bab860f7545682b6c2c245ea36173fc

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

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

<% 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, class_name: 'User'

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
honey-cms-0.5.1 lib/generators/cms/templates/type_model.rb