Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the generator of assets on rails 3.2

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

like image 322
rizidoro Avatar asked Feb 15 '12 20:02

rizidoro


People also ask

What does rake assets precompile do?

rake assets:precompile. We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application.

What is require_ tree in Rails?

The require_tree directive tells Sprockets to recursively include all JavaScript files in the specified directory into the output. These paths must be specified relative to the manifest file.

What are generators in Rails?

Resource GeneratorsA migration file that will create a new database table for the attributes passed to it in the generator. A model file that inherits from ApplicationRecord (as of Rails 5; see Note above) A controller file that inherits from ApplicationController. A view directory, but no view template files.


1 Answers

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
like image 105
Dylan Markow Avatar answered Sep 27 '22 18:09

Dylan Markow