Added filtering for has_many and habtm