title: Ruby on Rails Approve / Reject buttons
body: <p>My form is simple:</p>
  
  <pre><code>    &lt;%= form_for(@shop, remote: true, data: { confirm: "You sure?"}) do |fa| %&gt;
        &lt;%= fa.hidden_field :status, :value =&gt; 1 %&gt;
        &lt;%= fa.submit "Approve", class: "btn btn-large btn-success" %&gt;
      &lt;% end %&gt;
      &lt;%= form_for(@shop, remote: true, data: { confirm: "You sure?" }) do |fr| %&gt;
        &lt;%= fr.hidden_field :status, :value =&gt; 2 %&gt;
        &lt;%= fr.submit "Reject", class: "btn btn-large btn-danger" %&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>I want to update an attribute <code>status</code> of <code>@shop</code>. Pressing "Approve" should set it to 1, "Reject" - to 2 respectively. But now nothing happens when I click the buttons (except confirmation). I know I don't have something important and fundamental in my code, but I can't figure out what.</p>
  
  <p>Also, is there a way to write everything in one form_for? Like</p>
  
  <pre><code>&lt;%= form_for(@shop, remote: true, data: { confirm: "You sure?"}) do |fa| %&gt;
    &lt;%= fa.hidden_field :status_a, :value =&gt; 1 %&gt;
    &lt;%= fa.hidden_field :status_r, :value =&gt; 2 %&gt;
    &lt;%= fa.submit "Approve", class: "btn btn-large btn-success" %&gt;
    &lt;%= fa.submit "Reject", class: "btn btn-large btn-danger" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>PS: Shop controller</strong> has:</p>
  
  <pre><code>  def update
      if @shop.update_attributes(shop_params)
        flash[:success] = "Shop updated"
        redirect_to @shop
      else
        render 'edit'
      end
    end
  
    def edit
    end
  .
  .
    private
  
      def shop_params       
         params.require(:shop).permit(:title, :rating, :pic, :status,
                                      address_attributes: [:country, :state, :city, :street])
      end
  </code></pre>
  
  <p><strong>Server log</strong> when pressing Approve button:</p>
  
  <pre><code>Started PATCH "/shops/64" for 127.0.0.1 at 2014-08-12 12:52:36 +0400
  Processing by ShopsController#update as JS
    Parameters: {"utf8"=&gt;"✓", "shop"=&gt;{"status"=&gt;"1"}, "commit"=&gt;"Approve", "id"=&gt;"64"}
    User Load (0.6ms)  SELECT  "users".* FROM "users"  WHERE "users"."remember_token" = '5927a9415e68e7b293f8d1e24a709961bc260195' LIMIT 1
  Completed 500 Internal Server Error in 18ms
  
  NoMethodError (undefined method `update_attributes' for nil:NilClass):
    app/controllers/shops_controller.rb:35:in `update'
  
  
    Rendered /usr/lib/ruby/gems/1.9.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.1ms)
    Rendered /usr/lib/ruby/gems/1.9.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb (1.0ms)
    Rendered /usr/lib/ruby/gems/1.9.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb (1.1ms)
    Rendered /usr/lib/ruby/gems/1.9.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb (66.5ms)
  </code></pre>
  
  <p>35th line in ShopsController is</p>
  
  <pre><code>if @shop.update_attributes(shop_params)
  </code></pre>