Programmatic way to find associations? (ActiveRecord)

Is there a programmatic way to find the different associations that an
particular model has?

For example, if I have the following:

class File < ActiveRecord::Base
belongs_to :directory
has_many :comments
end

is there a way to get the list of symbols/strings that this class has
associated under the has_many association?

On Apr 10, 9:37 pm, gm gm [email protected].invalid wrote:

Is there a programmatic way to find the different associations that an
particular model has?

Take a look at YourClass.reflections and the various reflect_on_xxx
methods

Fred

Thanks…I could never find that on my own…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs