Syntax to skip creating tests, resources and helpers for 'rails generate controller'?

I read the help and tried the following command to skip the creation of tests, assets and support files

$ bin/rails generate controller home index --helper false --assets false --controller-specs false --view-specs false create- app/controllers/home_controller.rb route get "home/index" invoke erb create app/views/home create app/views/home/index.html.erb invoke rspec error false [not found] error false [not found] 

As you can see, the result above works, and only controller, routes and views generated. But since the last two lines are interesting:

 error false [not found] error false [not found] 

Obviously, the rails do not seem to resemble the syntax --option-name false . so is this error because i used the wrong syntax? If so, what is the right way? Thanks

+76
generator ruby-on-rails ruby-on-rails-3
Dec 26 '12 at 20:26
source share
4 answers

Try using --no- and then optionname :

 rails generate controller home index --no-helper --no-assets --no-controller-specs --no-view-specs 

If you want to change the default behavior each time the generator command is run, you can configure the default values ​​that you would like in the application.rb file - see How can I make sure Rails does not generate special tests for views and helpers? .

+151
Dec 26
source share
β€” -

To disable without adding options:

 # application.rb config.generators.assets = false config.generators.helper = false 
+71
Jun 13 '13 at 13:36 on
source share

Applications that only serve APIs will not require javascript , stylesheet , views , helpers . To skip these files in the generator / scaffold, add the code below in application.rb

 #to skip assets, scaffolds.css, test framework, helpers, view config.generators do |g| g.template_engine nil #to skip views g.test_framework nil #to skip test framework g.assets false g.helper false g.stylesheets false end 

check the link for more information about generators

+43
Mar 10 '15 at 11:31
source share

More briefly:

 rails g controller home index --no-assets --no-test-framework 
+23
Sep 10 '14 at 2:45
source share



All Articles