Tag Archives: associations

Testing associations with factory girl

Associations are very important when we are working with relational databases. Writing relations in models is easy but when it comes testing them, it is a painful task. Factory girl associations makes this easy. Before going into details, lets get … Continue reading

Posted in Ruby on Rails, Tutorials | Tagged , , | 8 Comments

How to get all associted models of rails model

I have Site Model and i wanted to find all associated models of Site model which are having belongs_to relationship.After doing lot headache, here is the solution i found has_many models of Site Model Site.reflect_on_all_associations.map{|mac| mac.class_name if mac.macro==:has_many}.compact=> [“Layout”, “User”, … Continue reading

Posted in Ruby on Rails | Tagged | Leave a comment