Forum: Ruby on Rails Multiple Nested Resources + named routes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
1665888814d628f34e4d40b93b522930?d=identicon&s=25 AryaAsemanfar (Guest)
on 2007-07-05 23:16
(Received via mailing list)

I'm not sure if this has been answered before but I couldn't find
anything in the few searches I did before posting.

Anyway, here is what I'm trying to do:

I have 3 resources: One, Two, and Three

map.resources :ones do |ones|
   ones.resources :threes, :name_prefix => "one_"

map.resources :twos do |twos|
   twos.resources :threes, :name_prefix => "two_"

map.resources :threes

Now, in my controllers and views, I can access the following three
sets of URL helpers (or named routes):

Now my question is how do *cleanly* determine which path method to

What I've done is defined in my Three controller a method called
"determine_threes_path" and it looks like this:

def determine_threes_path
   eval "#{path_method_prefix}threes_path"

and path_method_prefix is a method that determines the value "one_",
"two_", or "" depending on the values in the params hash.

I've done this for all the path methods that I need and then defined
them all as helper methods so they are accessible in the view as well.

Is there an existing solution to this problem or does anyone have any
suggestions on how I can do this in a more structured fashion?

Thank you in advanced for any help anyone can provide.
This topic is locked and can not be replied to.