2

I'm trying to implement basic social network features to allow users to add, delete friends, accept and decline friedship requests.

my user resource looks like this:

resources :users
    resources :friends, :controller => :relations
end

which generates this route user_friend DELETE /users/:user_id/friends/:id

But the problem is when I access /users/1, the generated link to the delete_user_friend_path looks like this: http://localhost:3000/users/5/friends/1

bassneck
  • 4,053
  • 4
  • 24
  • 32

1 Answers1

1

You need to pass the user into the helper:

delete_user_friend_path(@user, @friend)

It seems that you were doing:

delete_user_friend_path(@friend)

Which will fill in the :user_id parameter, and assume you want the same :id parameter as the page you are currently on.

Austin Taylor
  • 5,437
  • 1
  • 23
  • 29