如何默认配置Rails 3.2 + / 4生成.js而不是.js.coffee? [英] How to configure Rails 3.2+/4 to generate .js instead of .js.coffee by default?
问题描述
我看到了这个问题的许多变体,所有答案都只是建议从 Gemfile $中删除
咖啡轨
gem c $ c>(这一个和这一个)。
I have seen a number of variations of this question where all the answers simply suggest removing the coffee-rails
gem from the Gemfile
(this one and this one).
这不是我要的答案。我可能仍想在项目中编写一些CoffeeScript,我只希望JavaScript( .js
)是Rails生成器的默认设置。
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 (.js
) to be the default for the Rails generators.
这也意味着将重命名 .js.coffee
到 .js
的建议 每次我生成代码都不是理想的解决方案。
This also means the suggestions to rename .js.coffee
to .js
every time I generate code is not a desirable solution.
在Rails中是否可以进行一些配置更改 .js
为默认值,但仍启用CoffeeScript(资产管道仍应能够转换 .js.coffee
我可以写的文件)?
Is there some sort of configuration in Rails I can change to make .js
the default, but still leave CoffeeScript enabled (Asset Pipeline should still be able to transpile an .js.coffee
files that I may write)?
推荐答案
您可以通过自定义生成器配置。
config.generators do |g|
g.javascript_engine :js
end
# or
config.generators.javascript_engine = :js
您可以看到更多可用的配置选项此处。
You can see more available configuration options here.
这篇关于如何默认配置Rails 3.2 + / 4生成.js而不是.js.coffee?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!