Fixed has_and_belongs_to_many bug that occured when using rails 4.1.2