开发者

rails 3.1 coffeescript file extension problem

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜