On 11/25/06, John Topley
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Hi All,
>
> I''m working on a simple asset tracker application, but
I''ve got a bit
> confused about routes. Briefly, in my application there are users who
> can have many assets, and each asset can have many incomings or
> outgoings. In turn, each incoming or outgoing is assigned a category.
> I''m using Edge Rails.
>
> What I''d like to do is have every URL start with
/users/<username>/
> (e.g. /users/johntopley/assets/1). I know about :path_prefix and that
> you can nest resources, but I haven''t been able to work out how to
> achieve what I''m after.
You need to nest the resources. It''ll look like this:
map.resources :users do |u|
u.resources :assets
end
I''m not too clear on what you meant by the incomings, outgoings, and
categories, but you can continue to nest things if that''s what you
need. Don''t know if this is what you''ll need, but
it''s an example:
map.resources :users do |u|
u.resources :assets do |a|
a.resources :incomings, :outgoings, :categories
end
end
>
> This is my routes file:
>
> ActionController::Routing::Routes.draw do |map|
> map.home '''', :controller =>
''assets'', :action => ''index''
>
> map.resources :assets, :categories, :incomings, :outgoings, :users
>
> map.signin ''/signin'', :controller =>
''application'', :action =>
> ''signin''
> map.signout ''/signout'', :controller =>
''application'', :action =>
> ''signout''
> map.signup ''/signup'', :controller =>
''application'', :action =>
> ''signup''
>
> map.connect '':controller/:action/:id''
> end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---