views:

84

answers:

2

I am having a problem with restful routes and singular resources, originally I had this code in the show view on my account resource.

<%= link_to book.title, book_path(:search => book.title) %>

and it worked fine, then I changed account to be a singular resource, e.g

from

map.resources :accounts

to

map.resource :account

and now I get the error ...

book_url failed to generate from {:search=>"Dracula", :controller=>"books", :action=>"show"}, expected: {:controller=>"books", :action=>"show"}, diff: {:search=>"Dracula"}

remove the view line of code, and everything works fine. Also changing it to

<%= link_to book.title, :controller => "books", :action => "show", :search => book.title %>

makes it work.

I have created a standalone rails application demonstrate my problem in isolation http://github.com/jowls/singular_resource_bug

Is this a bug? brought about through some combination of singular resources and restful routes?

This was on rails 2.3.10

thanks

A: 

doublecheck your routes and their parameters with "rake routes" to see if your path still exists. I can't see any good reason why changing your account ressource should crash the book route.

Silvermind