Model associations


#1

I’ve got the folowing models associated with each other

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

‘–>’ means ‘belongs to’ in case someone wonders :wink:

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