Heroku rails - ActionView :: Template :: Error(意外的令牌:名称

时间:2017-07-13 16:49:40

标签: javascript ruby-on-rails heroku

当我在本地运行我的项目时,一切正常;但是,当我使用相同的ruby和rails版本部署到Heroku环境时,在尝试创建new text_message时出现错误。

这是日志中的错误:

ActionView::Template::Error (Unexpected token: name (tags) (line: 23, col: 8, pos: 352)
2017-07-13T16:44:31.188865+00:00 app[web.1]:   Rendered text_messages/new.html.erb within layouts/application (335.6ms)
2017-07-13T16:44:31.189147+00:00 app[web.1]: Completed 500 Internal Server Error in 344ms (ActiveRecord: 3.7ms)
2017-07-13T16:44:31.191422+00:00 app[web.1]: 
2017-07-13T16:44:31.191423+00:00 app[web.1]:     at new JS_Parse_Error (/tmp/execjs20170713-4-hxjahdjs:2659:11936)
2017-07-13T16:44:31.191419+00:00 app[web.1]: 
2017-07-13T16:44:31.191422+00:00 app[web.1]: Error
2017-07-13T16:44:31.191425+00:00 app[web.1]:     at token_error (/tmp/execjs20170713-4-hxjahdjs:2659:20759)
2017-07-13T16:44:31.191424+00:00 app[web.1]:     at js_error (/tmp/execjs20170713-4-hxjahdjs:2659:12155)
2017-07-13T16:44:31.191428+00:00 app[web.1]:     at /tmp/execjs20170713-4-hxjahdjs:2659:22152
2017-07-13T16:44:31.191425+00:00 app[web.1]:     at croak (/tmp/execjs20170713-4-hxjahdjs:2659:20622)
2017-07-13T16:44:31.191426+00:00 app[web.1]:     at semicolon (/tmp/execjs20170713-4-hxjahdjs:2659:21320)
2017-07-13T16:44:31.191428+00:00 app[web.1]:     at /tmp/execjs20170713-4-hxjahdjs:2659:21493
2017-07-13T16:44:31.191429+00:00 app[web.1]:     at block_ (/tmp/execjs20170713-4-hxjahdjs:2659:26198)):
2017-07-13T16:44:31.191426+00:00 app[web.1]:     at unexpected (/tmp/execjs20170713-4-hxjahdjs:2659:20847)
2017-07-13T16:44:31.191430+00:00 app[web.1]:      8: 
2017-07-13T16:44:31.191427+00:00 app[web.1]:     at simple_statement (/tmp/execjs20170713-4-hxjahdjs:2659:24179)
2017-07-13T16:44:31.191432+00:00 app[web.1]:     11: <%= javascript_include_tag "text_messages"%>
2017-07-13T16:44:31.191430+00:00 app[web.1]:      9: <%= javascript_include_tag "forms"%>
2017-07-13T16:44:31.191434+00:00 app[web.1]:   app/views/text_messages/new.html.erb:11:in `_app_views_text_messages_new_html_erb___3722409297874948535_69990020802000'
2017-07-13T16:44:31.191431+00:00 app[web.1]:     10: 
2017-07-13T16:44:31.191435+00:00 app[web.1]: 
2017-07-13T16:44:31.191432+00:00 app[web.1]:     12: 
2017-07-13T16:44:31.191433+00:00 app[web.1]:     13: <%= form_for @text_message, url: text_messages_path do |f| %>
2017-07-13T16:44:31.191435+00:00 app[web.1]: 
2017-07-13T16:44:31.191433+00:00 app[web.1]:     14:

我已经调试了一段时间了,我已经能够将错误固定在new.html.erb文件的这一行:

<%= javascript_include_tag "text_messages"%>

我将所有javascript都放在一个名为text_messages.js的文件中,当我将其包含在该行中时,该页面无效。

我首先检查了js文件的内容,看看是否有tags可能导致此问题的内容,但根本没有任何内容。

然后,我删除了text_messages.js文件的内容......并且错误仍然存​​在。即使在清除缓存之后。然后,我将text_messages.js中的javascript放在new.html.erb文件中,没有错误。

因此,结果是错误在于包含文件而不是实际文件或其内容......

不知道该怎么做,但我已经能够将错误缩小到上述......任何想法?

0 个答案:

没有答案