# How to get all associations info from an ActiveRecord model Class?

**URL:** <https://www.ruby-forum.com/t/how-to-get-all-associations-info-from-an-activerecord-model-class/170959>\
**Category:** Rails\
**Created:** [June 24, 2009, 1:19pm UTC](https://www.ruby-forum.com/t/how-to-get-all-associations-info-from-an-activerecord-model-class/170959 "2009-06-24T13:19:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [June 24, 2009, 1:19pm UTC](https://www.ruby-forum.com/t/how-to-get-all-associations-info-from-an-activerecord-model-class/170959/1 "2009-06-24T13:19:37Z")

</div>

I have defined in my Library model

belongs\_to :academy  
has\_many :document, :order =\> :title , :dependent =\> :destroy  
…

In one of my instance methods, I need to know what’s the order column  
defined  
so I could write  
selfl.class… but the how can I get the association and its  
options ?

thanks fyh

erwin

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [June 24, 2009, 2:16pm UTC](https://www.ruby-forum.com/t/how-to-get-all-associations-info-from-an-activerecord-model-class/170959/2 "2009-06-24T14:16:33Z")

</div>

Try:

self.class.reflect\_on\_association(:documents).options

See:

> **[ActiveRecord::Reflection::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Reflection/ClassMethods.html)**
>
> Reflection enables the ability to examine the associations and aggregations of Active Record classes and objects.

HTH,  
Nicholas
