Nested routes (2)

Rails 2.0.2

I am trying to rewrite my app routes to follow a good RESTFul pattern in
the 2.0app version…

I have a single resource ‘user’ and nested resource
map.resource :user, :controller => “users”, :member => {:network =>
:get} do |user|

user.resources :relationships, :collection => {:network => :get,
:direct => :get, }

end

which is called by formatted_network_user_relationships for the
current user (logged in)

a dynamic network structure is built (xml format) and display by a flash
object

but writing this, it just give me the first level, clicking on a flash
‘user’ object must call the relationships network for the clicked user

something like formatted_network_users_relationships(:clicked_id)
to get
/users/<clicked_id>/relationships/network.xml

should I defined another resource ‘users’ , or is this the case for a
domain name ?

what kind of new route I should write …

thanks

kad

to get
/users/<clicked_id>/relationships/network.xml

should I defined another resource ‘users’ , or is this the case for a
domain name ?

what kind of new route I should write …

thanks

kad

Don’t know if it’s the best one, but I found a solution, passing the
clicked_id as a parameter, and using it in the controller

so I have /user/relationships/network.xml?clicked_id= nnn

You should use named route for this case. So if you want
/users/<clicked_id>/relationships/network.xml

define name route like this:

map.network ‘/users/:clicked_id/relationships’, :controller =>
‘your_controller’, :action => ‘network’

when you do rake routes, you will see the URL helper method for this
definition use that with the clicked_id as the parameter.

On Dec 23, 2007 10:20 AM, Kad K. [email protected]
wrote:

a dynamic network structure is built (xml format) and display by a flash
domain name ?

what kind of new route I should write …

thanks

kad


http://www.rubyplus.org/
Free Ruby Screencasts