我正在关注 Fernando Villalobos 的React.js - Rails 开发人员指南AirPair 教程。
这里的目标是使用 Rails 和 React JS 构建一个简单的费用跟踪应用程序。
在Nesting Components: Listing Records部分,作者建议创建一个app/views/records/index.html.erb
文件如下:
<%# app/views/records/index.html.erb %>
<%= react_component 'Records', { data: @records } %>
和一个javascripts/components/records.js.coffee
文件如下:
# app/assets/javascripts/components/records.js.coffee
@Records = React.createClass
render: ->
React.DOM.div
className: 'records'
React.DOM.h2
className: 'title'
'Records'
然后,当我们访问时localhost:3000/records
,我们应该看到以下内容:
但是,当我访问时localhost:3000/records
,出现以下错误:
ExecJS::RuntimeError in Records#index
SyntaxError: [stdin]:7:10: cannot have an implicit value in an implicit object
<title>Expenses</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
特别是,导致问题的行似乎是:
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
知道problem是什么以及我如何使事情发挥作用吗?