urlgence and namespaces

1 view
Skip to first unread message

Luke Galea

unread,
Apr 15, 2008, 1:45:22 PM4/15/08
to resource_...@googlegroups.com
HI all,

So - resource_controller is working perfectly for me when I specify prefix and controller in my routes file, but when I try to DRY things up and use namespace, it causes urlgence to fail because the url method becomes namespaced as well and RC doesn't assume the module name factors into the method name.

ie:

map.resources :whatever, :prefix => 'something', :controller => 'something/whatever'

is okay.

but
namespace(:something) do |something|
 something.resources :whatever
end

isn't okay because the url method is now something_whatever_url.

Any ideas? Should we just make resource controller assume that if a controller is in a module that it's url method is prefixed? Safe assumption?

Luke Galea

James Golick

unread,
Apr 15, 2008, 3:15:40 PM4/15/08
to resource_...@googlegroups.com
It should work... that is, it should assume that your controller is namespaced.

which version of r_c/rails are you on?

Luke Galea

unread,
Apr 16, 2008, 8:59:31 AM4/16/08
to resource_controller
I'm running edge, although last updated a few weeks ago.

Specifically the problem is just the smart_url isn't expecting the
namespacing.. Everything else works though.

On Apr 15, 2:15 pm, "James Golick" <jamesgol...@gmail.com> wrote:
> It should work... that is, it should assume that your controller is
> namespaced.
>
> which version of r_c/rails are you on?
>

Tim Chater

unread,
Apr 17, 2008, 11:02:00 AM4/17/08
to resource_controller
On 16 Apr, 13:59, Luke Galea <ldga...@gmail.com> wrote:
> I'm running edge, although last updated a few weeks ago.
>
> Specifically the problem is just the smart_url isn't expecting the
> namespacing.. Everything else works though.

I'm not sure if this will help you, but I encountered difficulties
with r_c and namespacing a couple of months ago, and sent a patch (see
below... not sure if it's been incorporated yet). Since I did this
helpers.rb has been split so I think the changes now need to be made
in nested.rb and current_objects.rb.


Index: vendor/plugins/resource_controller/lib/resource_controller/
helpers.rb
===================================================================
--- vendor/plugins/resource_controller/lib/resource_controller/
helpers.rb (revision 457)
+++ vendor/plugins/resource_controller/lib/resource_controller/
helpers.rb (working copy)
@@ -24,7 +24,7 @@
# Used internally to return the model for your resource.
#
def model
- model_name.to_s.camelize.constantize
+ (self.class.parent.to_s + "::" +
model_name.to_s.camelize).constantize
end


@@ -121,7 +121,7 @@
# Like the model method, but for a parent relationship.
#
def parent_model
- parent_type.to_s.camelize.constantize
+ (self.class.parent.to_s + "::" +
parent_type.to_s.camelize).constantize
end

# Returns the current parent object if a parent object is
present.
Reply all
Reply to author
Forward
0 new messages