javascript_include_tag 抛出不受支持的方法 [英] javascript_include_tag throws unsupported method

查看:33
本文介绍了javascript_include_tag 抛出不受支持的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用 Rails 4.2.0 创建了一个新项目,并为登录页面创建了一个名为 Land 的控制器.所以,我在访问 http://localhost:3000/land/home 时遇到了这个错误:

I recently created a new project with Rails 4.2.0 and created a controller called Land for the landing page. So, I ran into this error upon visting http://localhost:3000/land/home:

Started GET "/" for ::1 at 2015-02-27 15:56:23 -0600
Processing by LandController#home as HTML
Rendered land/home.html.erb within layouts/application (0.0ms)
Completed 500 Internal Server Error in 5526ms

ActionView::Template::Error (TypeError: Object doesn't support this property or method
(in C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)):
3: <head>
4:   <title>Course</title>
5:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
6:   <%= javascript_include_tag 'application' %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__1279127835_98590860'


Rendered C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_source.erb (5.0ms)

Rendered C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_trace.html.erb (10.0ms)

Rendered C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_request_and_response.html.erb (1.0ms)

Rendered C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_web_console.html.erb (2.0ms)

Rendered C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/template_error.html.erb within rescues/layout (72.0ms)

有没有办法摆脱这个错误?还是bug?

Is there a way of getting rid of this error? Or is it a bug?

推荐答案

我最近为这个问题找到了另一个解决方案.1.9.0 中的 gem 'coffee-script-source'Windows 上使用 Rails 有一些问题.我使用 Gemfile 中的 gem 'coffee-script-source', '1.8.0' 恢复到以前的版本,这将解决您的问题.

I recently found another solution for this problem. gem 'coffee-script-source' in 1.9.0 has some issues with Rails on Windows. I reverted to the previous version using gem 'coffee-script-source', '1.8.0' in the Gemfile, this will resolve your problem.

解决此异常的另一种方法是将 Node.js 安装到您的机器上,错误应该安装后离开重新启动 rails 服务器.在重新启动终端并重新运行服务器之前,请确保将 Node.js 添加到 PATH 中.

Another way of solving this exception is installing Node.js onto your machine and the error should go away after installing & restarting rails server. Make sure that you add Node.js into your PATH before restarting the terminal(s) and rerun the server.

这篇关于javascript_include_tag 抛出不受支持的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆