Skip to content
This repository
Browse code

Add hook for add_resource_route

  • Loading branch information...
commit 39861395ffeaed6a164da5011f427f4184626b49 1 parent 476fa7a
Santiago Pastorino authored April 17, 2012
5  railties/CHANGELOG.md
Source Rendered
... ...
@@ -1,3 +1,8 @@
  1
+## Rails 3.2.4 (unreleased) ##
  2
+
  3
+*   Add hook for resource route's generator. *Santiago Pastorino*
  4
+
  5
+
1 6
 ## Rails 3.2.3 (unreleased) ##
2 7
 
3 8
 *   No changes.
2  railties/lib/rails/generators.rb
@@ -57,6 +57,7 @@ module Generators
57 57
         :orm => false,
58 58
         :performance_tool => nil,
59 59
         :resource_controller => :controller,
  60
+        :resource_route => true,
60 61
         :scaffold_controller => :scaffold_controller,
61 62
         :stylesheets => true,
62 63
         :stylesheet_engine => :css,
@@ -182,6 +183,7 @@ def self.hidden_namespaces
182 183
 
183 184
         [
184 185
           "rails",
  186
+          "resource_route",
185 187
           "#{orm}:migration",
186 188
           "#{orm}:model",
187 189
           "#{orm}:observer",
8  railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -14,13 +14,7 @@ class ResourceGenerator < ModelGenerator #metagenerator
14 14
       class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [],
15 15
                              :desc => "Actions for the resource controller"
16 16
 
17  
-      def add_resource_route
18  
-        return if options[:actions].present?
19  
-        route_config =  regular_class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
20  
-        route_config << "resources :#{file_name.pluralize}"
21  
-        route_config << " end" * regular_class_path.size
22  
-        route route_config
23  
-      end
  17
+      hook_for :resource_route, :required => true
24 18
     end
25 19
   end
26 20
 end
13  railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb
... ...
@@ -0,0 +1,13 @@
  1
+module Rails
  2
+  module Generators
  3
+    class ResourceRouteGenerator < NamedBase
  4
+      def add_resource_route
  5
+        return if options[:actions].present?
  6
+        route_config =  regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ")
  7
+        route_config << "resources :#{file_name.pluralize}"
  8
+        route_config << " end" * regular_class_path.size
  9
+        route route_config
  10
+      end
  11
+    end
  12
+  end
  13
+end

0 notes on commit 3986139

Please sign in to comment.
Something went wrong with that request. Please try again.