Nested Routes Show Action: What objects does it expect?
Posted
by
NoahClark
on Stack Overflow
See other posts from Stack Overflow
or by NoahClark
Published on 2012-06-11T22:38:42Z
Indexed on
2012/06/11
22:39 UTC
Read the original article
Hit count: 186
ruby-on-rails
|ruby-on-rails-3
Here is the relevant line from my rake routes:
client_note GET /clients/:client_id/notes/:id(.:format) notes#show
When I try passing in the objects like <%= client_note_path([client, @notes.first]) %>>
I get:
No route matches {:action=>"show", :controller=>"notes",
:client_id=>[#<Client id: 5, ... , #<Note id: 9, ...]}
Which made me think to try a client ID. So, I tried: <%= client_note_path([client.id, @notes.first]) %>
which gives me:
No route matches {:action=>"show", :controller=>"notes", :client_id=>[5,
#<Note id: 9,content: "He just bought a brand new bobcat, be sure to charg...",
client_id: 5, created_at: "2012-06-11 16:18:16",
updated_at: "2012-06-11 16:18:16">]}
Which, made me want to try just passing in a client ID. <%= client_note_path(client.id) %>
No route matches {:action=>"show", :controller=>"notes", :client_id=>5}
Still not what I'm looking for. I want to be able to show an individual note which can normally be found at a url like looks like: http://localhost:3000/clients/2/notes/3/
© Stack Overflow or respective owner