Forum: Ruby on Rails Creating menu items

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Andrew K. (Guest)
on 2007-07-13 00:52
Hi. I'm creating menu items on a webpage. For the sake of cleaner code
I'd like to create menu items in controller and just iterate through in
my rthml.

So, in modules I have created
class Menu
 def items
  review =, "main", true)
  edit =, "logoff", false)
  logoff =, "logoff", false)
  @items = [ review, edit, logoff ]

and in rhtml
 <% @menuitems.each do |item| %>
  <li class="selected"><%=, :action => item.action %></li>
 <% end %>

But I'm receiving "undefined method `items' for Menu:Class"
What is incorrect? Or is there any better "ruby way"??

Thanks a lot!!
This topic is locked and can not be replied to.