Create without form
I'm trying to create an object without a form, but just clicking on a link:
<%=link_to "Add as friend", user_friend_path(current_user,u), :method=>:post %>
Friend is a nested resource inside the user, in this link, current_user is the user and u 开发者_开发技巧will be the friend.
When I click on it, the following error appear:Routing Error
No route matches "/users/101/friends/86"
Someone can help me ?
Your probably trying to create a friendship, so your path helper should create the path for the join (friendships_path maybe?) model rather.
Addition I'm guessing that you're using a join model for your friendships? If so the create link "Add as friend" should probably create an entry for this model's table, right? So your link needs to point to proper path for this join model, not the nested user/friend path. But again, I'm just guessing, since I don't know your models.
精彩评论