How to set the action with form_for?

Timid Developer picture Timid Developer · Aug 12, 2011 · Viewed 19.3k times · Source

I created a new page on an existing controller.

I added 2 action methods on the controller: prompt_user and process_feedback.

So I get to the page via

redirect_to :controller => :users, :action => :prompt_user

And the form_for code looks like

<% form_for :user, @user do |f| %>

Which generates the following html

<form action="users/prompt_user" method="post">

Notice the action is prompt_user, where as I want to set it to process_feedback. I thought I could change the action with a button

<%= submit_tag "Process feedback" %>

But that didn't work.

So my question is how can I change the action to process_feedback?

Also, as you can probably tell, I'm very new to rails, so if I'm doing something especially obtuse, I'd love to find out what it is.

Answer

jonnii picture jonnii · Aug 12, 2011

This is from memory, but I think you can do something like this:

form_for :user, @user, :url => { :action => :prompt_user } do |f|