I'm receiving this ExecJS error message when I open my localhost, I don't know why, some help would be amazing.
当我打开localhost时,我收到了这个ExecJS错误消息,我不知道为什么,一些帮助会很神奇。
I got this on my localhost
Showing /.../conektec/app/views/layouts/application.html.erb where line #6 raised:
显示/…/ / application.html conektec / app / views /布局。erb,第6行提出:
SyntaxError: [stdin]:6:16: unexpected newline (in /.../conektec/app/assets/javascripts/orders.js.coffee)
SyntaxError: [stdin]:6:16:意想不到的新闻(in /…/conektec/app/assets/javascript /javascript /order .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 file
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)
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.
我已经尝试删除我的turbolinks,添加rubyracer gem,我已经安装了nodejs,我不知道错误在哪里。
I'm using: OS X Mavericks Ruby 2.0.0 Rails 4.1.1
我正在使用:OS X Mavericks Ruby 2.0.0 Rails 4.1.1
What's wrong? Thanks.
怎么了?谢谢。
1 个解决方案
#1
7
Your issue is in your CoffeeScript syntax (line 6, column 16, as it states in the error):
您的问题在CoffeeScript语法中(第6行,第16列,如错误中所示):
# The lack of indentation after the setupForm line is incorrect
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
Edit: 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.'
编辑:值得注意的是,无论何时出现ExecJS错误,通常都是一个很好的信号,表明您的coffecript语法有问题(从而导致编译错误)。在这种情况下,这并不是真正的JavaScript错误。
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:
为了解决您遇到的另一个问题,由于我不能对此进行评论,您需要对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)
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.
我不确定这些错误是怎么来的,因为它们是直接从铁路广播中复制过来的;试着非常小心你的压痕和咖啡。
#1
7
Your issue is in your CoffeeScript syntax (line 6, column 16, as it states in the error):
您的问题在CoffeeScript语法中(第6行,第16列,如错误中所示):
# The lack of indentation after the setupForm line is incorrect
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
Edit: 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.'
编辑:值得注意的是,无论何时出现ExecJS错误,通常都是一个很好的信号,表明您的coffecript语法有问题(从而导致编译错误)。在这种情况下,这并不是真正的JavaScript错误。
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:
为了解决您遇到的另一个问题,由于我不能对此进行评论,您需要对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)
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.
我不确定这些错误是怎么来的,因为它们是直接从铁路广播中复制过来的;试着非常小心你的压痕和咖啡。