# How to handle asset groups within groups?

**URL:** <https://www.ruby-forum.com/t/how-to-handle-asset-groups-within-groups/149997>\
**Category:** Rails\
**Created:** [October 2, 2008, 3:53am UTC](https://www.ruby-forum.com/t/how-to-handle-asset-groups-within-groups/149997 "2008-10-02T03:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [October 2, 2008, 3:53am UTC](https://www.ruby-forum.com/t/how-to-handle-asset-groups-within-groups/149997/1 "2008-10-02T03:53:30Z")

</div>

Hi Everyone,  
I’m stumped. Imagine I have a bunch of assets. I want to be able to  
group  
them together (like in graphics programs), and then be able to group  
them  
into further groups.

What is the best way to do this?

1. I could have two models, Asset and AssetGroup, where Asset has\_a url,  
and  
AssetGroup has\_many Assets and has\_many AssetGroups.

2. I could have one model: Asset, which has\_a url and has\_many Assets,  
where  
if it has a url it’s a “leaf” asset, and if it has some assets, it’s a  
“branch.” It could have a type field, too.

3. Something else?

The reason this is difficult is because I want to have other models be  
able  
to contain either an Asset or an Asset group, and treat them as the  
roughly  
the same thing.

How would you go about doing this?

Thanks  
~sean

---

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [October 2, 2008, 10:44pm UTC](https://www.ruby-forum.com/t/how-to-handle-asset-groups-within-groups/149997/2 "2008-10-02T22:44:43Z")

</div>

Thanks twice-over, Erol 🙂 I’ll look at those to see how they work
