Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add hook for add_resource_route

  • Loading branch information...
commit 17b8fd5540fd7f6e3cbfa48c0daa4051674647b7 1 parent 96cfadc
@spastorino spastorino authored
View
2  railties/lib/rails/generators.rb
@@ -52,6 +52,7 @@ module Generators
:orm => false,
:performance_tool => nil,
:resource_controller => :controller,
+ :resource_route => true,
:scaffold_controller => :scaffold_controller,
:stylesheets => true,
:stylesheet_engine => :css,
@@ -172,6 +173,7 @@ def self.hidden_namespaces
[
"rails",
+ "resource_route",
"#{orm}:migration",
"#{orm}:model",
"#{orm}:observer",
View
8 railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -17,13 +17,7 @@ class ResourceGenerator < ModelGenerator #metagenerator
class_option :http, :type => :boolean, :default => false,
:desc => "Generate resource with HTTP actions only"
- def add_resource_route
- return if options[:actions].present?
- route_config = regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ")
- route_config << "resources :#{file_name.pluralize}"
- route_config << " end" * regular_class_path.size
- route route_config
- end
+ hook_for :resource_route, :required => true
end
end
end
View
13 railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb
@@ -0,0 +1,13 @@
+module Rails
+ module Generators
+ class ResourceRouteGenerator < NamedBase
+ def add_resource_route
+ return if options[:actions].present?
+ route_config = regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ")
+ route_config << "resources :#{file_name.pluralize}"
+ route_config << " end" * regular_class_path.size
+ route route_config
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.