简体   繁体   中英

Javascript in assets not loading in Rails app

I have added test.js to /assets/javascripts/

test.js only contains two lines

window.alert(5 + 6);
document.write(5 + 6);

application.js includes the following

//= require jquery
//= require jquery_ujs
//= require_tree 
//= require test

Inside of my view I have the following

<%= javascript_include_tag ("test") %>

But when I load the view there is no window alert or other output

I have tried adding to my initializers/assets and restarting the server but no change

Rails.application.config.assets.precompile += %w( test.js )

Any help would be wonderful, I'm surely missing something quite obvious..

已解决-test.js的另一行javascript代码正在中断执行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM