Nik So
Nik So

Reputation: 16821

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.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?

Upvotes: 1

Views: 960

Answers (1)

MBO
MBO

Reputation: 31025

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

Upvotes: 3

Related Questions