Skip to content

Instantly share code, notes, and snippets.

@JeffWaltzer
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save JeffWaltzer/ca872115f41d763b13ae to your computer and use it in GitHub Desktop.

Select an option

Save JeffWaltzer/ca872115f41d763b13ae to your computer and use it in GitHub Desktop.
LIst all ActiveRecord models with relations
Rails.application.eager_load!
puts ActiveRecord::Base.descendants.map {|m| [ m.name, m.reflections.values.map{|r| "#{r.macro} #{r.name}"} ]}.select{|k,v| v.size>0}.to_h.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment