最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to configure Rails 3.2+4 to generate .js instead of .js.coffee by default? - Stack Overflow

programmeradmin1浏览0评论

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

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.

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

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

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

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.

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

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

Share Improve this question edited May 23, 2017 at 11:54 CommunityBot 11 silver badge asked Jun 15, 2014 at 18:07 jbranchaudjbranchaud 6,0879 gold badges49 silver badges75 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 21

You can do this by customising the generators config.

config/application.rb

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

# or
config.generators.javascript_engine = :js

You can see more available configuration options here.

Comment out gem 'coffee-rails', '~> 3.2.1' in your Gemfile

发布评论

评论列表(0)

  1. 暂无评论