Hi guys,
I''m having a problem with nested routes and I don''t know what
I''m missing.
I have a "products" resource, which has a "available"
collection action.
map.resources :courses, :member => { :confirm => :get}, :collection
=> { :available => :get }
Then I have the "users" resource, which has many "products"
map.resources :users, :has_many => [:subscriptions, :courses]
The problem is that if I try to access "available" products through a
user (/users/3/courses/available) I get redirected to the "show"
action with parameters:
Parameters: {"action"=>"show",
"id"=>"available", "user_id"=>"3",
"controller"=>"products"}
I can''t find the relevant section in the routing guide and I
can''t
figure it out.
Does anyone know what I am doing wrong?
Thanx a lot in advance.
--
Leonardo Mateo.
There''s no place like ~
--
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.
Hi Leonardo> map.resources :courses, :member => { :confirm => :get}, :collection > => { :available => :get } > > Then I have the "users" resource, which has many "products" > > map.resources :users, :has_many => [:subscriptions, :courses] >Assuming what you specified "products" is "courses". Change your routes as below map.resources :users do |user| user.resources :courses, :member => { :confirm => :get}, :collection => {available => :get } user.resources :subscriptions end Sijo -- Posted via http://www.ruby-forum.com/. -- 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 Sat, Jul 10, 2010 at 3:26 PM, Sijo k g <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi LeonardoHi Sijo> >> map.resources :courses, :member => { :confirm => :get}, :collection >> => { :available => :get } >> >> Then I have the "users" resource, which has many "products" >> >> map.resources :users, :has_many => [:subscriptions, :courses] >> > Assuming what you specified "products" is "courses". Change your > routes as belowYes, sorry, I mixed two applications with the same problem here.> > > map.resources :users do |user| > user.resources :courses, :member => { :confirm => :get}, :collection > => {available => :get } > user.resources :subscriptions > end >This worked like a charm. Thanx a lot! -- Leonardo Mateo. There''s no place like ~ -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.