Forum: Ruby on Rails Model associations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Adam (Guest)
on 2008-11-26 15:47
(Received via mailing list)
I've got the folowing models associated with each other

venture <--- component --> attribute --> service

'-->' means 'belongs to' in case someone wonders ;)

The thing is i want to show in the 'show' action for the venture
components ordered by the service

like so
@venture.services.each do |service|
      service.components.each do |component|
         = component.name
         = component.attribute.name

In the venture model I got how to have the attributes
Venture (part)
has_many :attributes_, :through=>:components, :source=>:attribute
has_many :components,:dependent=>:destroy

Component
belongs_to :attribute

So its easy but the problem is with getting the services the way i
want to
It's important for me to be able to do it in a simple way so I tried
all sorts of combinations like

has_many :services, :through=>:attributes_

Any ideas on this one? Is it possible this way through has_many and
belongs?

cheers
This topic is locked and can not be replied to.