orbit-basic/app/models/page.rb

37 lines
631 B
Ruby

class Page < Item
#include LayoutSupport
field :content
field :layout_name
field :layout_id
validates_presence_of :layout_name, :layout_id
referenced_in :layout
has_many :page_parts
def create_parts
page_layout = self.get_layout
page_layout.layout_parts.each do |p|
self.page_parts.create( :name => p.name, :i18n_variable_id => I18nVariable.create.id, :kind => 'text' )
end
end
def get_layout
Layout.find(layout_id)
end
protected
def setup_default_value
super
if self.layout_id
self.layout_name = get_layout.name
end
end
end