Orbit/app/models/page_part.rb

38 lines
784 B
Ruby

class PagePart
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :content, localize: true
field :kind
field :public_r_tag
field :public_r_tag_object_id, :default => nil
field :public_r_tag_option, :default => nil
field :page_title, localize: true
field :widget_path
field :widget_style
field :widget_field , :type => Array
field :widget_data_count
belongs_to :page
belongs_to :module_app
before_save :delete_empty_widget_field
after_save :update_parent
protected
def delete_empty_widget_field
if self.widget_field
self.widget_field.reject! { |wf| (wf[0].blank? || wf[1].blank?) }
end
# self.widget_field.delete("") if self.widget_field
end
def update_parent
self.page.save
end
end