Created
September 21, 2014 00:48
-
-
Save kiasaki/e32e5c356d332b76d28a to your computer and use it in GitHub Desktop.
Rails UID Concern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Uid | |
extend ActiveSupport::Concern | |
included do | |
before_create :generate_uid | |
end | |
def to_param | |
self.uid | |
end | |
private | |
def generate_uid | |
self.uid = rand(36**10).to_s(36) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment