Stopping Rails from autogenerating .coffee, .scss and helper modules

Everytime you generate new controller, Rails auto-generates some files like

$ rails g controller some_new_controller
 create app/controllers/some_new_controller_controller.rb
 invoke haml
 create app/views/some_new_controller
 invoke rspec
 create spec/controllers/some_new_controller_controller_spec.rb
 invoke helper
 create app/helpers/some_new_controller_helper.rb
 invoke rspec
 create spec/helpers/some_new_controller_helper_spec.rb
 invoke assets
 invoke coffee
 create app/assets/javascripts/some_new_controller.js.coffee
 invoke scss
 create app/assets/stylesheets/some_new_controller.css.scss

To stop rails from auto-generating un-nececssary helper files, specs and .coffee files you can configure it like

If you are not using .coffee at all then you can comment out gem 'coffee-script' in Gemfile.

Add these lines to application.rb:

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

or this one-liner does the same

config.generators.assets = false

 


Update:

You can also do

 config.generators do |generators|
   generators.javascripts false
   generators.helper false
   generators.view_specs false
   generators.helper_specs false
   generators.controller_specs false
   generators.model_specs false
 end

 

Some extra configs

generators.javascripts false
generators.helper false
generators.view_specs false
generators.helper_specs false
generators.controller_specs false
generators.model_specs false
generators.stylesheets false
generators.decorator_specs false
generators.decorator false

Sources:

http://stackoverflow.com/questions/7366273/how-do-i-turn-off-automatic-stylesheet-javascript-generation-on-rails-3-1

2 thoughts on “Stopping Rails from autogenerating .coffee, .scss and helper modules

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s