title: Rails form submit to controller action and jQuery modal
body: <p>I want a form to submit (POST) that a custom action in my controller that will perform an evaluation (based on the data from the form) and then pop up a jQuery model that has the results of that evaluation. The trick is, I want this modal to just pop over the form so that if they close the modal, they can go back and see/edit the form.</p>
  
  <p>I've tried something like the following, but it does not work. I get the following error:</p>
  
  <p><em>Missing template games/evaluate, application/evaluate with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}.</em></p>
  
  <p><strong>/app/controllers/games_controller.rb</strong></p>
  
  <pre><code>class ExercisesController &lt; ApplicationController
    #...    
    def evaluate
      if( params[:id] )
        found = Game.find(params[:id])
        @eval = found.evaluate_guess(params[:guess])
      end  
    end
    #...
  end
  </code></pre>
  
  <p><strong>/app/views/games/play.html.haml</strong></p>
  
  <pre><code>= semantic_form_for @games, :url =&gt; evaluate_path(@games) do |f|
    = f.semantic_errors
    = f.input :guess, 
      :as =&gt; :text
  = f.actions do
    = f.action :submit, :label =&gt; "Guess!",
      :button_html =&gt; { :action =&gt; :evaluate, :method =&gt; :post } 
  </code></pre>
  
  <p><strong>/app/views/games/_evaluation_modal.html.haml</strong></p>
  
  <pre><code>#evaluation_modal.modal.modal-wide.hide.fade
    = semantic_form_for @exercise, html: { class: 'modal-form' } do |f|
      .modal-header
      %h3 Results
  
      .modal-body
        #flashbar-placeholder
        %h2= CGI.unescapeHTML(@eval).html_safe
  </code></pre>
  
  <p><strong>/app/views/games/evaluate.js.coffee</strong></p>
  
  <pre><code>$('#evaluate').html(
    '&lt;%= escape_javascript render partial: "evaluation_modal"  %&gt;')
  $('#evaluation_modal').modal('show')
  </code></pre>
  
  <p><strong>/config/routes.rb</strong></p>
  
  <pre><code>#...
  get '/play/:id' =&gt; 'games#play', as: :play
  patch '/play/:id' =&gt; 'games#evaluate', as: :evaluate
  #...
  </code></pre>