9

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.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
Timid Developer
  • 143
  • 1
  • 1
  • 7

2 Answers2

18

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

form_for :user, @user, :url => { :action => :prompt_user } do |f|
jonnii
  • 28,019
  • 8
  • 80
  • 108
  • Btw, this is all available in the rails docs (http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html). – jonnii Aug 12 '11 at 18:59
2

Alternatively the same can be reached using form_tag with the syntax:

See my answer on this question: here https://stackoverflow.com/a/37145293/1248725

Community
  • 1
  • 1
juliangonzalez
  • 4,231
  • 2
  • 37
  • 47