The uniq option needs to be moved into a scope block. Note that the scope block needs to be the second parameter to has_many