Ruby missing template -


i have function in controller , render page, called thankyou. render works fine, after rails redirects me again thankyou, time can't find template. can't understand why rails renders me 2 times same template, differents results. function:

def create amount = params[:amount] nonce = params[:payment_method_nonce] if nonce.nil?   render :checkout else   result = braintree::transaction.sale(     amount: amount,     payment_method_nonce: nonce   )   session[:user_id] = nil   render :thankyou end end 

this form calls action create:

<%= form_tag '/create', remote: true, id: "form", method: "post" %>  <div class="col-md-12 text-left">   choose plan: <br>   <div>   <input class="collection_radio_buttons" id="plan_pro" name="amount" type="radio" value="0.99">   <label for="plan_pro">   <span class="fa-stack"><i class="fa fa-circle-o fa-stack-1x"></i><i class="fa fa-circle fa-stack-1x"></i></span>   <b>pro</b><br>   </label>   </div>   <div>   <input class="collection_radio_buttons" id="plan_premium" name="amount" type="radio" value="1.98" checked="checked">   <label for="plan_premium">   <span class="fa-stack"><i class="fa fa-circle-o fa-stack-1x"></i><i class="fa fa-circle fa-stack-1x"></i></span>   <b>premium</b><br>   </label>   </div>   <div>    <div id="paypal-container"> </div>   <input data-braintree-name="number" placeholder="card number" class="string optional form-control input-box mailcode-form" maxlenght="16">   <input data-braintree-name="cvv" placeholder="cvv" class="string optional form-control input-box mailcode-form" width="3" maxlenght="3">   <input data-braintree-name="expiration_date" placeholder="expiration date (e.g. 10/20)" class="string optional form-control input-box mailcode-form">  </div>   <div class="col-md-12 pull-right">      <input type="submit" class="signup-next" id="button_1" value="pay 0,99 €">      <input type="submit" class="signup-next" id="button_2" value="pay 1,98 €">   </div> <% end %> 

ps: log seems rails called action create twice. actual log after i've submitted form:

    started post "/create" 127.0.0.1 @ 2015-06-30 15:47:06 +0200 processing homecontroller#create js   parameters: {"utf8"=>"✓", "authenticity_token"=>"s2lg9bg4trbxoou4ewdbxhr0j1xtawrxy9hdsvjcbza=", "amount"=>"1.98", "payment_method_nonce"=>""}   rendered layouts/_social.html.erb (0.0ms)   rendered home/_thankyou.html.erb (2.4ms)   rendered home/thankyou.js (4.3ms) completed 200 ok in 16127ms (views: 8.4ms) [braintree] [30/jun/2015 13:47:38 utc] post /transactions 422   started post "/create" 127.0.0.1 @ 2015-06-30 15:47:22 +0200 processing homecontroller#create html   parameters: {"utf8"=>"✓", "authenticity_token"=>"s2lg9bg4trbxoou4ewdbxhr0j1xtawrxy9hdsvjcbza=", "amount"=>"1.98", "payment_method_nonce"=>"695c94a3-d219-44b6-af6f-cfec5dbb445f"} completed 500 internal server error in 16376ms  actionview::missingtemplate (missing template home/thankyou, application/thankyou {:locale=>[:it, :en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. searched in:   * "/home/marco/scrivania/mailcoding_web/app/views"   * "/home/marco/.rvm/gems/ruby-2.2.1/gems/kaminari-0.16.3/app/views" ):   app/controllers/home_controller.rb:117:in `create'     rendered /home/marco/.rvm/gems/ruby-2.2.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.5ms) 

try, in app/views/home/thankyou.js.erb file:

$('#signup-modal .modal-body').html("<%= j render_to_string('thankyou') %>"); 

and in :create action:

render js: :thankyou 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -