Description:
I created a class called MenuLink so I could create link objects for my navigation menus. I want to instantiate the list and have it available to all controllers in my applcation.
How I did it:
I created a file called menu_link.rb in app/models that contained
class MenuLink include Enumerable attr_accessor :name, :method
@@items =
def initialize() @@items.push(self) end
def self.each(&block) @@items.each(&block) end end
Then in my app/controllers/application.rb I put
before_filter :config_defaults
def config_defaults # More on this function later MenuLink.reset