Erwin
2009-Jun-24 11:16 UTC
how to get all associations info from an ActiveRecord model Class ?
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
Nicholas Henry
2009-Jun-24 12:15 UTC
Re: how to get all associations info from an ActiveRecord model Class ?
Try: self.class.reflect_on_association(:documents).options See: http://api.rubyonrails.org/classes/ActiveRecord/Reflection/ClassMethods.html HTH, Nicholas On Jun 24, 7:16 am, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote:> 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