Ruby on Rails: Can I do a "link_to" to call a create action?
- by sjsc
How would I correctly call the create action from a link_to? Here's the create action:
def create
recipe = Recipe.create(:name => "French fries")
redirect_to recipe
end
For example, I thought something like this might work:
<%= link_to "Create a default recipe", recipe_path, :method => :post %>
I'm not sure if that's a recommended (or even correct) way to do it. Any idea?