Skip to content

Plugin for generating identifiers for your ActiveRecord models

License

Notifications You must be signed in to change notification settings

m0wfo/Identifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Identifier

Solves a common pattern in models, i.e. specifying how unique identifiers are generated for a certain column. For example if a User has a UUID, or an Authorisation has a unique access_token.

Usage

In your ActiveRecord model:

class Authorisation < Activerecord::Base

has_identifier(:column_name) { SecureRandom.hex(16) }

end or

has_identifier(:column_name) do UUID.new.generate end

You get the idea :) Declaring has_identifier also protects :column_name from mass-assignment.

Copyright © 2010 Chris Mowforth, released under the MIT license

About

Plugin for generating identifiers for your ActiveRecord models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages