TypeError: Object doesn't support this propert

2020-03-03 07:03发布

I have created rails application where I created a database (empty). When I try to view my products page, I receive the following error on my http://localhost:3000/products page. Before migrating the database, the application did function. I am using therubyracer and am on 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

This is what I got on the Rails server:

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)

Thank you for any help.

8条回答
孤傲高冷的网名
2楼-- · 2020-03-03 07:37

The reason is because NodeJS is not installed. If you install it, the problem should go away.

However, this would work as well in application.js:

//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
// require_tree .

But this is just not the prefered method because all this does is disable rails functionality. For example, ActionCable will not work with this change.

查看更多
何必那么认真
3楼-- · 2020-03-03 07:47

I think Best Solution is Removing the slashes in application.js file like

= require jquery
= require jquery_ujs
= require turbolinks
= require_tree .
查看更多
甜甜的少女心
4楼-- · 2020-03-03 07:53

I removed the require_tree from application.js and it worked

//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
// require_tree .
查看更多
The star\"
5楼-- · 2020-03-03 07:57

I had this issue too, checkout the extensive solution on this thread, ExecJS::RuntimeError on Windows trying to follow rubytutorial by @Kevin P. Also,the solution by, @evedoevelli, on another thread: Rails ExecJS::ProgramError in Pages#home? works. I used the second solution with it been the most recent date-wise.

查看更多
戒情不戒烟
6楼-- · 2020-03-03 07:58

For me,solution was to remove-

 <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload'%>
 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

from

app\views\layout\application.html.erb

查看更多
戒情不戒烟
7楼-- · 2020-03-03 07:59

If you do not use layouts, put "layout false" in the controller file, just below class title:

class ABCController < ApplicationController "layout false" def index ... ..

查看更多
登录 后发表回答