Simulate PUT on a link, in Rails3
So far, I know that in Rails I can simulate a PUT request using a form which has a hidden input with name='_method'
and value='put'
, but I'm interested in simulating that for a link.
How can I have a link in a view that would fit this route:
match '/article/:id/publ开发者_StackOverflowish', :to => 'article#publish', :via => :put
The docs for link_to say you can specify a :method option that creates a form that is submitted on clicking the link.
link_to "Publish!", publish_article_path(article), :method => :put
Not sure what your route helper method would be (I assumed publish_article_path
- you should be able to figure it out with rake routes
from the command line. The :method
is the important part that will do the magic you want.
精彩评论