# Has\_many having another has\_many

**URL:** <https://www.ruby-forum.com/t/has-many-having-another-has-many/171397>\
**Category:** Rails\
**Created:** [July 1, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/has-many-having-another-has-many/171397 "2009-07-01T18:33:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 1, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/has-many-having-another-has-many/171397/1 "2009-07-01T18:33:15Z")

</div>

A person has\_many cars.

A car has\_many lights.

Can I write a person has\_many lights?

A snippet of code to help me understand will help.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 1, 2009, 6:45pm UTC](https://www.ruby-forum.com/t/has-many-having-another-has-many/171397/2 "2009-07-01T18:45:57Z")

</div>

2009/7/1 Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> A person has\_many cars.
> 
> A car has\_many lights.
> 
> Can I write a person has\_many lights?
> 
> A snippet of code to help me understand will help.

Try person has\_many :lights, :through =\> :cars

See

> **[ActiveRecord::Associations::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html)**
>
> Associations are a set of macro-like class methods for tying objects together through foreign keys.

for lots of examples of such things.

Colin
