Guest User

Untitled

a guest
May 4th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment