diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-19 18:11:37 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-19 18:12:54 +0100 |
commit | 562154fcbc8f36f94c986a3253c73ae88e2c1146 (patch) | |
tree | 69f03eef669c16786dc71385decacfa6e856a06c /railties/lib | |
parent | 541194f641c960efe739b16f76999f47742d12ba (diff) | |
download | rails-562154fcbc8f36f94c986a3253c73ae88e2c1146.tar.gz rails-562154fcbc8f36f94c986a3253c73ae88e2c1146.tar.bz2 rails-562154fcbc8f36f94c986a3253c73ae88e2c1146.zip |
Controller generator now creates routes as well [#4233 state:resolved]
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/generators/rails/controller/controller_generator.rb | 6 | ||||
-rw-r--r-- | railties/lib/generators/rails/resource/resource_generator.rb | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/railties/lib/generators/rails/controller/controller_generator.rb b/railties/lib/generators/rails/controller/controller_generator.rb index 91470be833..5d2e36b499 100644 --- a/railties/lib/generators/rails/controller/controller_generator.rb +++ b/railties/lib/generators/rails/controller/controller_generator.rb @@ -8,6 +8,12 @@ module Rails template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") end + def add_routes + actions.reverse.each do |action| + route %{get "/#{file_name}/#{action}" => "#{file_name}##{action}"} + end + end + hook_for :template_engine, :test_framework, :helper end end diff --git a/railties/lib/generators/rails/resource/resource_generator.rb b/railties/lib/generators/rails/resource/resource_generator.rb index 5acb839f39..02c1c39209 100644 --- a/railties/lib/generators/rails/resource/resource_generator.rb +++ b/railties/lib/generators/rails/resource/resource_generator.rb @@ -16,6 +16,7 @@ module Rails class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" def add_resource_route + return if options[:actions].present? route "resource#{:s unless options[:singleton]} :#{pluralize?(file_name)}" end |