diff options
author | Lucas Mazza <lucastmazza@gmail.com> | 2014-06-19 18:42:52 -0300 |
---|---|---|
committer | Lucas Mazza <lucastmazza@gmail.com> | 2014-06-24 14:06:03 -0300 |
commit | 4b173b8ed90cb409c1cdfb922914b41b5e212cb6 (patch) | |
tree | 3430c6846f93209f75819b6a4576dcf3ab547591 /railties/lib/rails/generators | |
parent | ef686a60951342a189cc82bfc4823180a6cf3a32 (diff) | |
download | rails-4b173b8ed90cb409c1cdfb922914b41b5e212cb6.tar.gz rails-4b173b8ed90cb409c1cdfb922914b41b5e212cb6.tar.bz2 rails-4b173b8ed90cb409c1cdfb922914b41b5e212cb6.zip |
Add a '--skip-routes' flag for the Controller generator.
This way it is possible to skip the addition of the 'get "foo/bar"' routes when
generating a controller.
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r-- | railties/lib/rails/generators/rails/controller/controller_generator.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb index 7588a558e7..fbecab1823 100644 --- a/railties/lib/rails/generators/rails/controller/controller_generator.rb +++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb @@ -2,6 +2,8 @@ module Rails module Generators class ControllerGenerator < NamedBase # :nodoc: argument :actions, type: :array, default: [], banner: "action action" + class_option :skip_routes, type: :boolean, desc: "Dont' add routes to config/routes.rb." + check_class_collision suffix: "Controller" def create_controller_files @@ -9,8 +11,10 @@ module Rails end def add_routes - actions.reverse.each do |action| - route generate_routing_code(action) + unless options[:skip_routes] + actions.reverse.each do |action| + route generate_routing_code(action) + end end end |