Fix previous commit

This commit is contained in:
chris 2012-12-03 17:38:55 +08:00
parent 6543491a53
commit bdcfb46294
2 changed files with 21 additions and 17 deletions

View File

@ -27,7 +27,7 @@ class Layout < DesignFile
end end
def save_pages def save_pages
self.design.pages.each(&:save) self.design.pages.each(&:generate_parts)
end end
end end

View File

@ -26,10 +26,7 @@ class Page < Item
# embeds_many :custom_images, :class_name => 'Image', as: :design_image # embeds_many :custom_images, :class_name => 'Image', as: :design_image
protected def generate_parts
def create_parts
if self.new_record? || self.design_id_changed?
page_design = self.design page_design = self.design
parent = self.parent parent = self.parent
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
@ -47,6 +44,13 @@ class Page < Item
end end
end end
end end
protected
def create_parts
if self.new_record? || self.design_id_changed?
generate_parts
end
end end
def delete_empty_frontend_field def delete_empty_frontend_field