gpt4 book ai didi

ruby-on-rails - 类型错误 : Object doesn't support this property or method

转载 作者:数据小太阳 更新时间:2023-10-29 07:20:21 26 4
gpt4 key购买 nike

我创建了 Rails 应用程序,我在其中创建了一个数据库(空)。当我尝试查看我的产品页面时,我在 http://localhost:3000/products 上收到以下错误页。在迁移数据库之前,应用程序可以正常运行。我正在使用 therubyracer 并且在 Windows 7 上。

ExecJS::ProgramError in Products#index
Showing C:/RailsInstaller/DevKit/home/JP/nameofapp/app/views/layouts/application.html.erb where line #16 raised:

TypeError: Object doesn't support this property or method
(in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line #16):

13 <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
14
15 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
16 <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
17 <%= csrf_meta_tags %>
18
19 </head>

Rails.root: C:/RailsInstaller/DevKit/home/JP/nameofapp

这是我在 Rails 服务器上得到的:

Started GET "/products" for 127.0.0.1 at 2015-04-23 22:28:06 -0400
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM
"schema_migrations"
Processing by ProductsController#index as HTML
Product Load (0.0ms) SELECT "products".* FROM "products"
Rendered products/index.html.erb within layouts/application (4.0ms)
Completed 500 Internal Server Error in 3391ms

ActionView::Template::Error (TypeError: Object doesn't support this property or
method
(in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/
assets/javascripts/turbolinks.js.coffee)):
13: <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.mi
n.js"></script>
14:
15: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolin
ks-track' => true %>
16: <%= javascript_include_tag 'application', 'data-turbolinks-track' => t
rue %>
17: <%= csrf_meta_tags %>
18:
19: </head>
app/views/layouts/application.html.erb:16:in `_app_views_layouts_application_h
tml_erb__912949727_56715336'


Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8
/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.0ms)
Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8
/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
(6.0ms)
Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8
/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within
rescues/layout (27.0ms)

感谢您的帮助。

最佳答案

错误发生是因为在找到位于 app/assets 中的正确 Assets 时出现问题。要解决此问题,您可以按照以下步骤操作。

gem 'coffee-script-source', '1.8.0' 添加到 Gemfile 中并运行 bundle install 然后运行bundle update coffee-script-source重启 rails 服务器或者有一个肮脏的解决方法是将代码从

<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>

<%= stylesheet_link_tag "default", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "default", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>

但请注意,此解决方法并不能真正解决应用程序问题,它只会让您的应用程序在没有预期样式表和 javascript 的情况下运行。

关于ruby-on-rails - 类型错误 : Object doesn't support this property or method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29838237/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com