11175
(-- --)
1
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!
11175
(-- --)
2
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"
11175
(-- --)
3
Thorsten Mueller wrote:
<%= link_to_unless_current "Search by Name",
search_by_name_customers_path()
-%>
Perfect! That did the trick! Thanks so much.
11175
(-- --)
4
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?
11175
(-- --)
5
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() -%>
11175
(-- --)
6
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?
11175
(-- --)
7
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() -%>