class Page < Item field :content field :app_frontend_url field :theme_id, :type => BSON::ObjectId, :default => nil belongs_to :design belongs_to :module_app has_many :page_parts, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :page_parts, :allow_destroy => true # embeds_many :custom_images, :class_name => 'Image', as: :design_image def create_parts page_design = self.design page_design.layout.layout_parts.each do |p| self.page_parts.create( :name => p.name, :i18n_variable => I18nVariable.create, :kind => 'text' ) if p.editable? end end def is_home? self.parent ? false : true end end