Tested with rails 4.2.1 should work with rails 5
If you are working with pagination on a pages And you want to sort them on e.g. Rating and many records holds the same value for rating Then you can’t rely on what the database throw back at you when you ask for a batch on pages
Without uuis_stamper this will not be relyable @cakes = Cake.order(:rating).page(params).per(32))
Notice you can also use it with numbers if you store them in the db as strings
Usage
Add to gemfile gem ‘uuid_stamper’, git: ‘git://github.com/maxgronlund/uuid_stamper.git’
Uniqifying a string/number UNIQIFYED_STRING = SOME_NOT_UNIQ_STRING.to_uniq
Turn the same string back to whas it was before for viewing on the screen SOME_NOT_UNIQ_STRING = UNIQIFYED_STRING.from_uniq
Don’t use from_uniq on Fixum and Float use plain old Ruby .to_i or to_f
Example solving the problem cake.rating = params.to_uniq Then the pagination will work @cakes = Cake.order(:rating).page(params).per(32))