运行Ruby On Rails TypeError: 对象不支持此属性或方法

运行Ruby On Rails 报错:

ActionView::Template::Error (TypeError: 对象不支持此属性或方法):
    4:     <title>ToyApp</title>
    5:     <%= csrf_meta_tags %>
    6: 
    7:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    8:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    9:   </head>
   10: 
 

错误截图可以看到 ExecJS::ProgramError

 

解决办法有两个:

1)删除js文件的第15行,重启 rail server
C:\toy_app\app\assets\javascripts\application.js
15: //= require_tree .

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require turbolinks
//= require_tree .


2)安装nodejs,重启rail server

$ node -v
v12.13.1

基于版本:

$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]

$ rails -v
Rails 5.1.7
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值