my routes file has the following lines map.resources :players, :has_many => :matches map.resources :tourney, :has_many => :matches now I want to be able to display all the matches played by a player and also all the matches played in the entire tournament. I have two routes available tourney_matches GET /tourney/:tourney_id/matches {:controller=>"matches", :action=>"index"} player_matches GET /player/:player_id/matches {:controller=>"matches", :action=>"index"} both these paths call the same action in the matches controller, so how is this supposed to work? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
You will have to add an "if" on your index action, if there is a "params[:tourney_id]" load the tourney and then load the matches, otherwise load the player and the matches. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Thu, Jan 15, 2009 at 1:14 AM, Maulin pa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > my routes file has the following lines > > map.resources :players, :has_many => :matches > map.resources :tourney, :has_many => :matches > > now I want to be able to display all the matches played by a player and > also all the matches played in the entire tournament. I have two routes > available > > tourney_matches GET /tourney/:tourney_id/matches > {:controller=>"matches", :action=>"index"} > > player_matches GET /player/:player_id/matches {:controller=>"matches", > :action=>"index"} > > both these paths call the same action in the matches controller, so how > is this supposed to work? > -- > 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Maurício Linhares wrote:> You will have to add an "if" on your index action, if there is a > "params[:tourney_id]" load the tourney and then load the matches, > otherwise load the player and the matches. >Thanks! -- 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---