how Ruby black magic works for 'has_many' and 'belongs_to'