views:

91

answers:

2

When I generated a scaffold for a model class named menuitem, it generates a class file for menuitem, but in the database creates menu_item and refers to the class in the views and controller as menu_item. This may be causing me quite a headache as im genereating a newsted show link, but its failing telling me missing method. The rake routes tells me the show route should be menu_menu_item, but when i do:

 <td><%= link_to 'Show', menu_menu_item(@menu) %></td>

it doesnt work.

Is that because of the funky two word class name?

A: 

The Pluralizer shows you show things should be named according to the Rails' conventions.

John Topley
I see that, but why does it turn into menu.menu_items instead of menu.menuitems? In pluralizer the only time it shows as menu_items is under database table.
midas06
+2  A: 

You must have generated either menu_item or menuItem or MenuItem. It doesn't know where one word stops and another starts unless you tell it.

Also, for your link_tos, you just need to append _path:

<td><%= link_to 'Show', menu_menu_item_path(@menu) %></td>

Well, actually, that looks a little wrong to me. That looks like you're trying to go to a single item, which I think will require you to specify both the menu and the item:

<td><%= link_to 'Show', menu_menu_item_path(@menu, @menu_item) %></td>

And to all the menu items in a menu:

<td><%= link_to 'Show', menu_menu_items_path(@menu) %></td>
Ian Terrell