I am having a small problem creating a link.
My view:
<%= link_to 'slet', blog_comments_path(c.blog, c), :confirm => 'Er du sikker?', :method => :delete %>
Output:
http://localhost:3000/blogs/5/comments.6
Where it should by:
http://localhost:3000/blogs/5/comments/6
blog_comments_path
is the route for all comments for a blog. if you want just a comment, you have to use blog_comment_path
(check with rake routes
, I might be wrong with the syntax. But you get the idea.)
Had the same problem, because in my routes I had
resource :products
and not
resources :products
Don't forget the plural ;)
And always check your routes :)
我认为这种较短的语法可行:
<%= link_to 'slet', [c.blog, c], :confirm => 'Er du sikker?', :method => :delete %>
In my case I had urls like users.1
when I wanted users/1
I had to add the line:
resources :users
to my routes.rb file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.