mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add hook for add_resource_route
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
## Rails 3.2.4 (unreleased) ##
|
||||
|
||||
* Add hook for resource route's generator. *Santiago Pastorino*
|
||||
|
||||
|
||||
## Rails 3.2.3 (unreleased) ##
|
||||
|
||||
* No changes.
|
||||
|
||||
@@ -57,6 +57,7 @@ module Rails
|
||||
:orm => false,
|
||||
:performance_tool => nil,
|
||||
:resource_controller => :controller,
|
||||
:resource_route => true,
|
||||
:scaffold_controller => :scaffold_controller,
|
||||
:stylesheets => true,
|
||||
:stylesheet_engine => :css,
|
||||
@@ -182,6 +183,7 @@ module Rails
|
||||
|
||||
[
|
||||
"rails",
|
||||
"resource_route",
|
||||
"#{orm}:migration",
|
||||
"#{orm}:model",
|
||||
"#{orm}:observer",
|
||||
|
||||
@@ -14,13 +14,7 @@ module Rails
|
||||
class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [],
|
||||
:desc => "Actions for the resource controller"
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user