Instantly share code, notes, and snippets.

Embed
What would you like to do?
.irbrc convenience method to cleanly display Rails model associations in Rails Console
# is ActiveRecord loaded? (so it doesn't blow up IRB)
unless defined?(ActiveRecord::Base).nil?
class ActiveRecord::Base
def self.get_associations
self.reflect_on_all_associations.map{|m| {m.class_name => m.macro} }.inject(&:merge)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment