Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 0.26 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do you get the names of models that have MyObject has_many of?
  2. class MyObject
  3.     has_many :other_objects
  4.  
  5. class OtherObject
  6.     belongs_to :my_object
  7.        
  8. MyObject.reflect_on_all_associations.map{|a| a.name.to_s} #=> ["other_objects"]
  9.        
  10. MyClass.reflections