I want to build up a basic menu system for my application. Each
‘section’ has it’s own left hand menu and I was planning on handling
that by defining a ‘menu’ method within each controller, which I’d
pass (along with any other menus I needed at that point) in an
instance variables called @menus. So I’d get something like
My application layout looks for @menus and displays the menus in the
left hand side. Problem is I can’t access link_to from my controller
as it’s a helper. The FAQ mentions writing your own helpers within
the controller but in this case I want to access a default helper
from the controller.
Question 1: Why is there this restriction?
Question 2: How do I get around it?
Many thanks for any suggestions. I’ve got ‘The Book’ so if there are
clues in there I’ve missed I’m happy for page numbers. Or if I am
just doing it the wrong way - educate me as to the right way please.
I took a look but I was trying to avoid creating a partial for each
menu (which I think this method implies). What I ended up doing was
keeping my menu definitions in the controller (which I believe is the
right place for it). It looks something like