Reputation: 28071
I have a resource nested in another:
resource :users do
resource :posts
end
The official guide says I should have this url:
/users/:id/posts/:id
To show
update
edit
or delete
the posts. But in fact I have:
ruby-1.9.2-p290 > app.users_posts_path(1,2)
=> "/users/posts.1?=2"
What's going wrong?
Upvotes: 1
Views: 717
Reputation: 1786
Did you try to see your routes? in you console type:
$ bundle exec rake routes
Usually user_posts_path is the GET request for listing items (are you sure that in your route name user is plural?), so you just need to provide the first parameter that represents your :id, related to users.
Upvotes: 0
Reputation: 124419
You need to be using standard plural routes, not singular, so use resources
instead of resource
:
resources :users do
resources :posts
end
Upvotes: 2