handling to has_many and has_one relations