TypeError: Object doesn't support this property or method

后端 未结 8 1426
梦如初夏
梦如初夏 2021-01-05 20:53

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

相关标签:
8条回答
  • 2021-01-05 21:19

    The error occurs because there is some problem finding the correct assets which are located in app/assets. To resolve the issue, you can following below steps.

    Add gem 'coffee-script-source', '1.8.0' into Gemfile and run bundle install then Run bundle update coffee-script-source Restart rails server Or there is a dirty workaround which is to change the code from

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

    to

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

    But note this workaround doesn't really resolve the application issue, it just makes your application works without expected stylesheets and javascripts.

    0 讨论(0)
  • 2021-01-05 21:23

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

    = require jquery
    = require jquery_ujs
    = require turbolinks
    = require_tree .
    
    0 讨论(0)
  • 2021-01-05 21:25

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

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

    0 讨论(0)
  • 2021-01-05 21:29

    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.

    0 讨论(0)
  • 2021-01-05 21:30

    I removed the require_tree from application.js and it worked

    //= require jquery 
    //= require jquery_ujs 
    //= require turbolinks 
    // require_tree .
    
    0 讨论(0)
  • 2021-01-05 21:31

    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.

    0 讨论(0)
提交回复
热议问题