Ruby on Rails link_to With put Method

link_to thinks that :method => :put is part of the path hash. You have to tell it otherwise. Wrap your path in brackets.

link_to 'Activate', {:action => :activate_user, :id => user.id}, :method => :put

Now link_to will recognize :method => :put as an option, not part of the link's path.

As a side note, you should try to use route helpers instead of path hashes whenever possible. Keeps things nice and tidy, and avoids nit-picky situations like this.


Updated - The link_to helper will do a GET unless a method is specified.

Its better specifying the exact request type, instead of match in your routes file. How about replacing match by put in routes as :

put '/admin/users/:id/activate' => 'admins#activate_user', :as => 'activate_user'

link_to 'Activate', activate_user_path(user.id), method: :put

The activate_user method should reside in admins controller. The docs has more info on link_to helper.