The mongoid slug gem solves the slugging problem:
-
https://github.com/digitalplaywright/mongoid-slug
By default slugs are generated using stringex, and Model.find is
clever enough to know when to find by slug or when to find by id.
I am maintaining this gem and there are a lot of details about
slugging that are non-trivial if you want to solve the problem well.
If the slug is permanent and you do not use things like CanCan
load_and_authorize_resource a simpler solution will probably work
well. However, it is not advisable to replace the bson id field with a
user-defined slug.