link_to problem in RoR 2.0

Hello.

I've got code from pre RoR 2.0 that is simply a link that a user clicks on to go to a search form and it works great.

<%= link_to_unless_current "Search by Name", :action => "search_by_name" -%>

But in the 2.0 world, this now goes to the show method and it fails since it's looking for an id.

Is there a route or something that I need to add or modify? For this model, I just have the standard route - map.resources :customers

Thanks!

Thorsten Mueller wrote:

map.resources :customers, :collection => ["search_by_name"]

Unfortunately, that gives me an error "Couldn't find Custoemr with ID=search_by_name"

Thorsten Mueller wrote:

<%= link_to_unless_current "Search by Name", search_by_name_customers_path() -%>

Perfect! That did the trick! Thanks so much.

Ooops! Something else broke now.

My route looks like this: map.resources :customers, :collection => ["search_by_name"]

I also have a link menu link: <%= link_to_unless_current "List", :action => "list" -%>

When I click on that link I get this error. Couldn't find Customer with ID=list

In my controller I have a list

def list search criteria end

Any ideas?

just the same as above (replace controller with the right name in plural): map.resources :controllers, :collection => ["list"]

and for the link: <%= link_to_unless_current "List", list_controllers_path() -%>

Thorsten Mueller wrote:

just the same as above (replace controller with the right name in plural): map.resources :controllers, :collection => ["list"]

and for the link: <%= link_to_unless_current "List", list_controllers_path() -%>

Sorry for not being clearer... these would use the same resource. Can I have 2 collection values on 1 resource?

Sorry for not being clearer... these would use the same resource. Can I have 2 collection values on 1 resource?

sure, it's map.resources :customers, :collection => ["search_by_name", "list"]

and for the link: <%= link_to_unless_current "List", list_customers_path() -%>