jbranchaud jbranchaud - 1 year ago 174
CoffeeScript Question

How to configure Rails 3.2+/4 to generate .js instead of .js.coffee by default?

I have seen a number of variations of this question where all the answers simply suggest removing the

gem from the
(this one and this one).

This is not the answer that I am looking for. I may still want to write some CoffeeScript in the project, I just want JavaScript (
) to be the default for the Rails generators.

This also means the suggestions to rename
every time I generate code is not a desirable solution.

Is there some sort of configuration in Rails I can change to make
the default, but still leave CoffeeScript enabled (Asset Pipeline should still be able to transpile an
files that I may write)?

Answer Source

You can do this by customising the generators config.


config.generators do |g|
  g.javascript_engine :js

# or
config.generators.javascript_engine = :js

You can see more available configuration options here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download