title: Ruby on rails AASM Change transition on button click
body: <p>My question is very simple: how can I change <code>aasm</code> transitions on button click? What should I put in my view?</p>
  
  <p>I have two buttons: <code>Approve</code> and <code>Reject</code>. My states look like this:</p>
  
  <pre><code>  aasm :column =&gt; 'state' do
      state :pending, :initial =&gt; true
      state :approved
      state :rejected
  
      event :approve do
        transitions :to =&gt; :approved, :from =&gt; [:pending]
      end
  
      event :reject do
        transitions :to =&gt; :rejected, :from =&gt; [:pending]
      end
    end
  </code></pre>
  
  <p>UPDATE:
  My params are these: </p>
  
  <p><code>{"utf8"=&gt;"✓",
   "_method"=&gt;"put",
   "authenticity_token"...",
   "commit"=&gt;"APP",
   "id"=&gt;"65"}</code>. </p>
  
  <p>And this is how I access action from the view:</p>
  
  <pre><code>= form_for([:admin, shop], method: :put, data: { confirm: "You sure?" }) do |f|
    = f.submit "Approve", :controller =&gt; :shops, :action =&gt; :approve
  </code></pre>
  
  <p>My controller code:</p>
  
  <pre><code>def approve
    @shop = Shop.find(params[:id])
    @shop.approve!
  end
  </code></pre>
  
  <p>Routes:</p>
  
  <pre><code>namespace :admin do
    get "shops/:id/approve" =&gt; "shops#approve"
  </code></pre>