public
Description: resources_controller rails plugin: rc makes RESTful controllers fun
Homepage: http://plugins.ardes.com/doc/resources_controller
Clone URL: git://github.com/ianwhite/resources_controller.git
Click here to lend your support to: resources_controller and make a donation at www.pledgie.com !
enclosing_resource_name is the name of the mapped enclosing resource (which may 
not be the class name underscored).
This keeps parity with resource_name, and allows sending params to the 
enclosing_resource_path like enclosing_resource_path(enclosing_resource_name => 
{:enabled => true})
ianwhite (author)
Fri Oct 10 16:35:22 -0700 2008
commit  40174b572fa933173d5d3c1983eaad7da015b13f
tree    ff4b9869683f22e3112882198948c255f3746e50
parent  264608d09733b602cb3a4e97db7c0a9cc10c56a6
...
628
629
630
631
 
632
633
634
...
781
782
783
 
784
785
786
...
628
629
630
 
631
632
633
634
...
781
782
783
784
785
786
787
0
@@ -628,7 +628,7 @@ module Ardes#:nodoc:
0
       
0
       # returns the name of the immediately enclosing resource
0
       def enclosing_resource_name
0
-        enclosing_resource.class.name.underscore
0
+        @enclosing_resource_name
0
       end
0
       
0
       # returns the resource service for the controller - this will be lazilly created
0
@@ -781,6 +781,7 @@ module Ardes#:nodoc:
0
         update_name_prefix(options[:name_prefix] || (options[:name_prefix] == false ? '' : "#{name}_"))
0
         enclosing_resources << resource
0
         enclosing_collection_resources << resource unless options[:is_singleton]
0
+        instance_variable_set("@enclosing_resource_name", options[:name])
0
         instance_variable_set("@#{name}", resource)
0
         instance_variable_set("@#{options[:as]}", resource) if options[:as]
0
       end
...
15
16
17
18
19
20
21
22
23
24
 
 
 
 
 
25
26
27
28
29
 
 
30
31
32
33
34
35
36
37
...
54
55
56
57
58
 
...
15
16
17
 
 
18
19
20
21
 
22
23
24
25
26
27
28
 
 
 
29
30
31
32
33
34
 
35
36
37
...
54
55
56
 
57
58
0
@@ -15,23 +15,23 @@ describe "ResourcesController (in general)" do
0
   it "resources_controller_for :forums, :in => [:user, '*', '*', :comment] should raise argument error (no multiple wildcards in a row)" do
0
     lambda { @controller.resources_controller_for :forums, :in => [:user, '*', '*', :comment] }.should raise_error(ArgumentError)
0
   end
0
-  
0
-  
0
 end
0
 
0
 describe "ResourcesController#enclosing_resource_name" do
0
   before do
0
-    @controller = ForumsController.new
0
+    @controller = TagsController.new
0
+    info = mock_model(Info, :tags => [])
0
+    @controller.stub!(:current_user).and_return(mock_model(User, :info => info))
0
+    @controller.stub!(:recognized_route).and_return(ActionController::Routing::Routes.named_routes[:account_info_tags])
0
+    @controller.send :load_enclosing_resources
0
   end
0
 
0
-  it "should be the class name underscored" do
0
-    @controller.instance_variable_set('@enclosing_resources', [mock_model(User)])
0
-    @controller.enclosing_resource_name.should == 'user'
0
+  it "should be the name of the mapped enclosing_resource" do
0
+    @controller.enclosing_resource_name.should == 'info'
0
   end
0
 end
0
 
0
 describe "A controller's resource_service" do
0
-  
0
   before do
0
     @controller = ForumsController.new
0
   end
0
@@ -54,4 +54,4 @@ describe "deprecated methods" do
0
       @controller.save_resource
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments