hi, I''m trying to setup a route next to my resources :users So this gives me the basic routes (incl. users/:id) But now I''d like to show users through their username (like this: users/:username) How should I do that? I''ve got my routes setup like this at the moment: (the users/:username) does work now, but all the rest doesn''t work (for the users controller) resource :account, :controller => "users" match ''/users/:username'' => ''users#show'' resources :users, :user_sessions, :homes, :shouts, :activations match ''/register/:activation_code'' => ''activations#new'', :as => :register match ''/activate/:id'' => ''activations#create'', :as => :activate root :to => "homes#index" Thx ;) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 11/2/10, mattyh88 <mathew.hucks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > > I''m trying to setup a route next to my > resources :users > > So this gives me the basic routes (incl. users/:id) > But now I''d like to show users through their username (like this: > users/:username) > > How should I do that? > > I''ve got my routes setup like this at the moment: (the > users/:username) does work now, but all the rest doesn''t work (for the > users controller) > > resource :account, :controller => "users" > > match ''/users/:username'' => ''users#show'' > > resources :users, :user_sessions, :homes, :shouts, :activationsI am not really an expert with routes, but if I am not mistaken, this has to do with rules precedece. That is, your match ''/users/:username''... will have precedence over resources :users.... You should place resources before any match. Perhaps others with more experience will be able to help further. Regards, Fidel. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you for the reply. But if i put the resources first, then my match users/:username doesnt work. So it''s true what you say, first route will be used. On 2 nov, 20:05, Fidel Viegas <fidel.vie...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11/2/10, mattyh88 <mathew.hu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > hi, > > > I''m trying to setup a route next to my > > resources :users > > > So this gives me the basic routes (incl. users/:id) > > But now I''d like to show users through their username (like this: > > users/:username) > > > How should I do that? > > > I''ve got my routes setup like this at the moment: (the > > users/:username) does work now, but all the rest doesn''t work (for the > > users controller) > > > resource :account, :controller => "users" > > > match ''/users/:username'' => ''users#show'' > > > resources :users, :user_sessions, :homes, :shouts, :activations > > I am not really an expert with routes, but if I am not mistaken, this > has to do with rules precedece. That is, your match > ''/users/:username''... will have precedence over resources :users.... > You should place resources before any match. > > Perhaps others with more experience will be able to help further. > > Regards, > > Fidel.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.