开发者

rails 3.1 coffeescript file extension problem

开发者 https://www.devze.com 2023-03-16 18:00 出处:网络
I have this stock rails 3.1 app, before even adding anything, I was testing to see if the assets are working as advertised

I have this stock rails 3.1 app, before even adding anything, I was testing to see if the assets are working as advertised

so i created this app/assets/javascripts/test.coffee

where test.coffee is just a

alert "hi"

When I navigate to http://127.开发者_JAVA百科0.0.1:3000/assets/test.coffee, I do see

(function() {
  alert("hi");
}).call(this);

But if I do http://127.0.0.1:3000/assets/test.js, I get routing error; but I thought this is the correct behavior, not the above one. What have I done wrong?


Try renaming your your js file to test.js.coffee

Coffee extension indicates that this file should be preprocessed with coffee processor, same as:

  • index.html.haml is just index.html with haml processor or
  • style.css.sass is just style.css with sass processor
0

精彩评论

暂无评论...
验证码 换一张
取 消