Add this gem to your Gemfile:
gem 'activerecord-ulid'
Then, run bundle install
.
in your model:
class User < ActiveRecord::Base
attribute :id, :ulid
end
you can add a prefix to the ulid:
class User < ActiveRecord::Base
attribute :id, :ulid, prefix: 'usr_'
end
Bug reports and pull requests are welcome on GitHub at https://github.com/seuros/activerecord-ulid.
The gem is available as open source under the terms of the MIT License.