rails 6.0.3
(Assuming a project that does not use * Minitest
*)
rails g controller <controller name> <action name>
Will create ** unnecessary files ** in addition to controller
and view
.
To avoid this, create the following files in the rails
project,
When executing the rails g controller
command
** Prevent files other than controller
and view
from being created **.
config/initializers/generators.rb
Rails.application.config.generators do |g|
g.assets false
g.helper false
g.skip_routes true
end
If creating the above file is troublesome,
Execute the rails g controller
command with the following three options added.
Terminal
rails g controller <Controller name> <Action name> --no-assets --no-helper --skip-routes
The above has the following merits.
-** stylesheets files are not created under ʻapp / assets / **. -** Helper file is not created under ʻapp / helpers /
.
- Routing is not added to config / routes.rb
**.
Recommended Posts