Refactor logic out of controller into category model
Add back has_and_belongs_to_many in category model