Hello, I have the following scenario: Models: provider (has_and_belongs_to_many) level (has_and_belongs_to_many) levels_providers At the moment, I''m attempting a page that will list all of the providers. I have this working perfectly, but I want each provider that is listed to also list the levels that are associated with it. I haven''t been able to get my head around this. I can provide more information, but I''m not sure where to go at this point. Thanks for any help! Jonathan -- 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 -~----------~----~----~----~------~----~------~--~---
wentwj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-10 02:51 UTC
Re: display variable from a relationship
Assuming the models are set up correctly each provider object can access it''s levels in something similar to: for level in provider.levels do #stuff end provider.levels should give you every level associated with that provider. Similarly, level.providers will give you all the providers associated with any given leve. On Oct 9, 7:36 pm, Jonathan Stegall <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > > I have the following scenario: > > Models: > > provider (has_and_belongs_to_many) > level (has_and_belongs_to_many) > levels_providers > > At the moment, I''m attempting a page that will list all of the > providers. I have this working perfectly, but I want each provider that > is listed to also list the levels that are associated with it. I haven''t > been able to get my head around this. I can provide more information, > but I''m not sure where to go at this point. Thanks for any help! > > Jonathan > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Perfect. Thanks for your help. wentwj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Assuming the models are set up correctly each provider object can > access it''s levels in something similar to: > > for level in provider.levels do > #stuff > end > > provider.levels should give you every level associated with that > provider. > > Similarly, level.providers will give you all the providers associated > with any given leve. > > On Oct 9, 7:36 pm, Jonathan Stegall <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>-- 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 -~----------~----~----~----~------~----~------~--~---