# Creating menu items

**URL:** <https://www.ruby-forum.com/t/creating-menu-items/109268>\
**Category:** Rails\
**Created:** [July 12, 2007, 10:52pm UTC](https://www.ruby-forum.com/t/creating-menu-items/109268 "2007-07-12T22:52:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewkendall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@andrewkendall](https://www.ruby-forum.com/u/andrewkendall)\
**Post date:** [July 12, 2007, 10:52pm UTC](https://www.ruby-forum.com/t/creating-menu-items/109268/1 "2007-07-12T22:52:34Z")

</div>

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 = MenuItem.new(stringReview, “main”, true)  
edit = MenuItem.new(stringEditQuestions, “logoff”, false)  
logoff = MenuItem.new(stringLogoff, “logoff”, false)  
@items = [review, edit, logoff]  
end  
end

and in rhtml

 \<% @menuitems.each do |item| %\> - \<%= item.name, :action =\> item.action %\>
 \<% end %\>

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

Thanks a lot!!  
Andrew
