title: Rails: Two Different Submit buttons in a form
body: <p>I'm trying to create a simple form with two different submit buttons: one which will do a normal submit, and one which will do an ajax submit and render a partial. But I'm not sure how to do this because both go towards the same create action. I tried something like this:</p>
  
  <p>/views/layouts/_form.html.erb:</p>
  
  <pre><code>&lt;div id="theform"&gt;
  &lt;%= form_for(@user, :remote =&gt; true, :form_to_validate =&gt; 'user') do |f| %&gt;
  
      Name: &lt;div id='name'&gt;&lt;%= f.text_field :name %&gt;&lt;/div&gt;&lt;br/&gt;
      Email: &lt;div id='email'&gt;&lt;%= f.text_field :email %&gt;&lt;/div&gt;&lt;br/&gt;
      Phone Number: &lt;div id='phone_number'&gt;&lt;%= f.text_field :phone_number%&gt;&lt;/div&gt;&lt;br/&gt;
      &lt;%= f.submit "Normal Submit", name:'normal' %&gt;
      &lt;%= f.submit "Ajax Submit" %&gt;
  
  &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>app/controllers/user_controller.rb:</p>
  
  <pre><code>class UsersController &lt; ApplicationController
  
  def new
      @user = User.new
  end
  
  def create
      @user = User.new(params[:user])
      if params[:normal]
          render :partial =&gt; "layouts/user"
      end
  end
  </code></pre>
  
  <p>EDIT: this may seem like an odd task but it was an assignment given to me to demonstrate I could do it both ways. I know how to do the AJAX submit and the normal submit separately but my confusion is with having two submits in the form! :)</p>