Considering an existing database of normal Mongoid documents, I’m implementing unique slugs for these documents, and have overwritten the find method as such:
def self.find(id)
Post.any_of({:_id => id}, {:slug => id}).first
end
However, when I run Post.all or Post.first in the console, it always returns nil. Works fine on classes that I have no overwritten the find method.
How can I override this with keeping the functionality of other methods?
Instead of overwriting find, I just created a new method find_by_id_or_slug and updated my code appropriately.