Module: RsMenu
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/rs_menu.rb
Instance Method Summary collapse
- #navigation(type) ⇒ Object
- #navigation_item(primary, item, block = nil) ⇒ Object
- #render_with_subs(items, primary, item) ⇒ Object
Instance Method Details
#navigation(type) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/concerns/rs_menu.rb', line 29 def (type) Proc.new do |primary| SimpleNavigation.config.autogenerate_item_ids = false begin items = ::Menu.find(type.to_s).pages.asc(:lft).to_a items.select { |i| i.parent_id.nil? && !i.name.blank? && i.enabled }.each do |item| render_with_subs(items, primary, item) end rescue Exception => exception Rails.logger.error exception. Rails.logger.error exception.backtrace.join("\n") capture_exception(exception) if respond_to?(:capture_exception) items end end end |
#navigation_item(primary, item, block = nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/concerns/rs_menu.rb', line 20 def (primary, item, block=nil) url = item.redirect.blank? ? item.fullpath : item.redirect if block.nil? primary.item(item.slug, item.name, url, item.) else primary.item(item.slug, item.name, url, item., &block) end end |
#render_with_subs(items, primary, item) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/concerns/rs_menu.rb', line 7 def render_with_subs(items, primary, item) subs = items.select { |i| i.parent_id == item.id && !i.name.blank? && i.enabled } if subs.empty? block = nil else block = Proc.new do |sub_nav| subs.each { |sub| render_with_subs(items, sub_nav, sub) } end end cr = item.clean_regexp (primary, item, block) end |