Hi --
I have gerated a scaffold_resource for "news" like so:
script/generate scaffold_resource news <fields>
I have also added a route to routes.rb
map.resources :news
I have an application-wide layout that contains a menu with the entry:
<%= link_to("News", news_path) %>
Now, the odd thing is that this generates <applicationurl>/news from most pages, but the same entry points to <applicationurl>/news/1 from within the news/1 page and from within the edit page for news 1. Similar it points to <applicationurl>/2 from the show and edit pages for news 2. When a news_path occurs anywhere on an news edit or show page, it does not link to the index action but to the show action for that specific record.
I have a couple of other models/views/controllers which all work fine, only the news part shows this odd (and definitely wrong) behavior.
I tried to add :singular => :news to the route definition, but that did not help.
Is this a bug in RoR?
No. There can only be one method called news_path, and either it is the singular named route or the plural one.
I would recommend:
map.resources :news, :singular => "news_item"
Then you can do:
<%= link_to item.title, news_item_path(item) %> <%= link_to "All news", news_path %>
That will separate the singular from the plural, and it actually makes more sense linguistically too.
David