2

I'm doing some testing, where it could be really nice, if I could ask a class what associations it has. Just like this example:

class Car < ActiveRecord::Base
  # Relationships
  has_many    :sellers
  has_many    :adverts
  has_many    :images
end

And then do something like...

Car.associations #=> [:sellers, :adverts, :images]

1 Answer 1

3

You want reflect_on_all_associations.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.