![payment payment]()
本文介绍了Listings#index错误中的ExecJS :: RuntimeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 当我打开我的localhost 时,我收到此 ExecJS错误消息,我不知道为什么,一些帮助会很惊人。 我在我的本地主机上有这个 显示/.../conektec/app/views/layouts/application.html.erb第6行: p> 语法错误:[stdin]:6:16:意外换行(在/.../conektec/app/assets/javascripts/orders.js.coffee中) ActionView :: Template :: Error(SyntaxError:[stdin]:2:73:unmatched) /Users/hbendev/startups/conektec/conektec/app/assets/javascripts/orders.js.coffee)): 3:< head> 4:< title> Conektec< / title> 5:<%= stylesheet_link_tag'application',media:'all','data-turbolinks-track'=>真实%> 6:<%= javascript_include_tag'application','data-turbolinks-track'=>真实%> 7:<%= javascript_include_taghttps://js.stripe.com/v2/%> 8:<%= csrf_meta_tags%> 9:<%= tag:meta,:name => stripe-key,:content => ENV [STRIPE_PUBLIC_KEY]%> 这是我的orders.js.coffee文件 jQuery - > Stripe.setPublishableKey($('meta [name =stripe-key]')。attr('content')) payment.setupForm() payment = setupForm: - > $('#new_order')。submit - > $('input [type = submit]')。attr('disabled',true) Stripe.card.createToken($('#new_order'),payment.handleStripeResponse) false handleStripeResponse:(status,response) - > if status == 200 alert(response.id) else alert(response.error.message) 这是我的application.html.erb文件 < DOCTYPE html> < html> < head> < title> Conektec< / title> <%= stylesheet_link_tag'application',media:'all','data-turbolinks-track'=>真实%> <%= javascript_include_tag'application','data-turbolinks-track'=>真实%> <%= javascript_include_taghttps://js.stripe.com/v2/%> <%= csrf_meta_tags%> <%= tag:meta,:name => stripe-key,:content => ENV [STRIPE_PUBLIC_KEY]%> < / head> < body> <%= render'layouts / header'%> < div class =container> <%flash.each do | name,msg | %> <%if msg.is_a?(String)%> < div class =alert alert-<%= name.to_s =='notice'?success:danger%> alert-dismissable> < button type =buttonclass =closedata-dismiss =alertaria-hidden =true>& times;< / button& <%= content_tag:div,msg,:id => flash _#{name}%> < / div> <%end%> <%end%> <%= yield%> <%= render'layouts / footer'%> < / div> < / body> < / html> 我已经尝试删除我的 turbolinks ,添加 rubyracer gem,我安装了 nodejs ,我不知道错误在哪里。 我使用的是: OS X Mavericks Ruby 2.0.0 Rails 4.1.1 出现了什么问题? 感谢 。解决方案您的问题是CoffeeScript语法(第6行第16列,因为它在错误中说明): #在setupForm行之后缺少缩进 payment = setupForm: - > $('#new_order')。submit - > $('input [type = submit]')。attr('disabled',true) Stripe.card.createToken($('#new_order'),payment.handleStripeResponse) false #Make it this payment = setupForm: - > $('#new_order')。submit - > $('input [type = submit]')。attr('disabled',true) Stripe.card.createToken($('#new_order'),payment.handleStripeResponse) false 编辑:值得注意的是,每当出现ExecJS错误时,它通常是一个很好的迹象您的CoffeeScript语法有一个问题(因此导致编译错误)。这不是一个实际的JavaScript错误在这种情况下。' 要解决您遇到的其他问题,由于我不能评论,您需要缩进您的 handleStripeResponse 函数,以便它嵌套在您的付款对象下面: jQuery - > ; Stripe.setPublishableKey($('meta [name =stripe-key]')。attr('content')) payment.setupForm() payment = setupForm: - > $('#new_order')。submit - > $('input [type = submit]')。attr('disabled',true) Stripe.card.createToken($('#new_order'),payment.handleStripeResponse) false handleStripeResponse:(status,response) - > if status == 200 alert(response.id) else alert(response.error.message) 我不知道你有这些错误,认为他们直接从Railscasts复制;尝试非常小心使用CoffeeScript缩进。 I'm receiving this ExecJS error message when I open my localhost, I don't know why, some help would be amazing.I got this on my localhostShowing /.../conektec/app/views/layouts/application.html.erb where line #6 raised:SyntaxError: [stdin]:6:16: unexpected newline (in /.../conektec/app/assets/javascripts/orders.js.coffee) ActionView::Template::Error (SyntaxError: [stdin]:2:73: unmatched ) (in /Users/hbendev/startups/conektec/conektec/app/assets/javascripts/orders.js.coffee)): 3: <head> 4: <title>Conektec</title> 5: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 6: <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 7: <%= javascript_include_tag "https://js.stripe.com/v2/" %> 8: <%= csrf_meta_tags %> 9: <%= tag :meta, :name => "stripe-key", :content => ENV["STRIPE_PUBLIC_KEY"] %>Here is my orders.js.coffee filejQuery -> Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content')) payment.setupForm()payment = setupForm: -> $('#new_order').submit -> $('input[type=submit]').attr('disabled', true) Stripe.card.createToken($('#new_order'), payment.handleStripeResponse) falsehandleStripeResponse: (status, response) -> if status == 200 alert(response.id) else alert(response.error.message)Here's my application.html.erb file<!DOCTYPE html><html><head> <title>Conektec</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= javascript_include_tag "https://js.stripe.com/v2/" %> <%= csrf_meta_tags %> <%= tag :meta, :name => "stripe-key", :content => ENV["STRIPE_PUBLIC_KEY"] %></head><body><%= render 'layouts/header' %><div class="container"> <% flash.each do |name, msg| %> <% if msg.is_a?(String) %> <div class="alert alert-<%= name.to_s == 'notice' ? "success" : "danger" %> alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <%= content_tag :div, msg, :id => "flash_#{name}" %> </div> <% end %> <% end %> <%= yield %> <%= render 'layouts/footer' %></div></body></html>I already tried deleting my turbolinks, adding the rubyracer gem, I have nodejs installed, I don't know where's the error.I'm using:OS X MavericksRuby 2.0.0Rails 4.1.1What's wrong? Thanks. 解决方案 Your issue is in your CoffeeScript syntax (line 6, column 16, as it states in the error):# The lack of indentation after the setupForm line is incorrectpayment = setupForm: -> $('#new_order').submit -> $('input[type=submit]').attr('disabled', true) Stripe.card.createToken($('#new_order'), payment.handleStripeResponse) false# Make it thispayment = setupForm: -> $('#new_order').submit -> $('input[type=submit]').attr('disabled', true) Stripe.card.createToken($('#new_order'), payment.handleStripeResponse) falseEdit: it's worth noting that whenever there is an ExecJS error, it's usually a pretty good sign that there's an issue with your CoffeeScript syntax (thus causing a compilation error). It's not an actual JavaScript error in this case.'To fix the OTHER issue you're having, since I can't comment, you need to indent your handleStripeResponse function so that it is nested underneath your payment object:jQuery -> Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content')) payment.setupForm()payment = setupForm: -> $('#new_order').submit -> $('input[type=submit]').attr('disabled', true) Stripe.card.createToken($('#new_order'), payment.handleStripeResponse) false handleStripeResponse: (status, response) -> if status == 200 alert(response.id) else alert(response.error.message)I'm not sure how you have these errors, considered they are copied directly from the Railscasts episode; try to be very careful about your indentation with CoffeeScript. 这篇关于Listings#index错误中的ExecJS :: RuntimeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-15 03:34