How do I turn off automatic stylesheet/javascript generation on Rails 3.1?

孤者浪人 提交于 2019-11-29 23:41:22

Add these lines to application.rb:

config.generators.stylesheets = false
config.generators.javascripts = false

New syntax is rails generate controller Resources --no-assets.

Don't forget you can also use g in place of generate. And you can skip the creation of a controller helper using the --no-helper flag.

For just one time, use:

rails generate controller controller_name --no-assets

An update on @Dmitry Maksimov's answer for Rails 4.2. You can disable generation of controller-specific asset files by default with the following in your config/application.rb file (source: the guide):

config.generators do |g|
  g.assets false
end

My whole options:

config.generators do |g|
    g.stylesheets = false
    g.javascripts = false
    g.test_framework  :rspec, fixture: false
    g.template_engine :haml
    g.fixture_replacement :factory_girl, dir: 'spec/factories'
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!