From 909ca19456a4a45fbcf65c11a0924d544c656599 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 9 May 2012 04:31:04 +0800 Subject: [PATCH] Fix bugs in sub_menu --- app/models/page.rb | 2 +- lib/parsers/parser_common.rb | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index df321d04..5a742e92 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -29,7 +29,7 @@ class Page < Item def create_parts page_design = self.design 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)} + 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 page_design.layout.layout_parts.each do |layout_part| current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} current_part = self.page_parts.build(:name => layout_part.name) unless current_part diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 28600980..be676544 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -111,19 +111,21 @@ module ParserCommon # sub_menus def parse_sub_menus(body = nil, page = nil, id = nil, edit=nil) body.css('sub_menu').each do |sub_menu| - menu_page = Page.find(sub_menu['id']) + menu_page = Page.find(sub_menu['id']) rescue nil res = '' - res << "
" - res << "

#{menu_page.i18n_variable[I18n.locale]}

" - res << "" - res << "" - res << "
" fragment = Nokogiri::HTML::DocumentFragment.new(body, res) sub_menu.swap(fragment) end