Sha256: 97d37b9ca78d0b4ce5c022807c7966a0e41903d194c911c7c7920887ba8bf2c3
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module DynamicMenu module InheritableMenus mattr_accessor :menu @@menu = Hash.new def get_current_menu path = Rails.root.join('app/menus') full_path = path + "#{params[:controller]}/#{params[:action]}.rb" second_chance = path + "#{params[:controller]}/#{try_again? params[:action]}.rb" logger.debug("Dynamic Menu:\n\r\tFirst Chance: #{params[:action]}\n\r\tSecond Chance: #{try_again? params[:action]}") if File.exists?(full_path) load full_path "#{params[:action]}_menu".classify.constantize.new(self) elsif File.exists?(second_chance) #Depending on the action (for example edit) it should look for a relationship (:create=:new or :update=:edit load second_chance "#{try_again? params[:action]}_menu".classify.constantize.new(self) end end def try_again? action if action == "create" return "new" elsif action == "update" return "edit" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dynamic_menu-3.0.2 | lib/dynamic_menu/inheritable_menus.rb |