15

Every time I create a controller, rails generate a controler_name.js and a controller_name.css file on app/assets folder. I already disable the config.assets.enabled param on application.rb but this not solve my problem. How can I disable the generator for those files when creating controller ?

Thanks

rizidoro
  • 13,073
  • 18
  • 59
  • 86

1 Answers1

36

You can pass --skip-assets to your command to prevent these files from being created:

rails g controller foo --skip-assets

If you want something more permanent, you can turn it off altogether. Add this to config/application.rb (from How do I turn off automatic stylesheet/javascript generation on Rails 3.1?)

config.generators.stylesheets = false
config.generators.javascripts = false
Community
  • 1
  • 1
Dylan Markow
  • 123,080
  • 26
  • 284
  • 201
  • 14
    Alternatively: ```config.generators.assets = false``` – tdahlke Sep 27 '12 at 14:01
  • 1
    I use rails 5 and it warn `Expected string default value for '--template-engine'; got false (boolean)` but replace `false` with `nil` works fine - silently disable. – oklas Feb 10 '17 at 09:58
  • Thanks @oklas, I had the same challenge in Rails-5+ – Dan Dec 25 '19 at 04:08