Plugin for generating identifiers for your ActiveRecord models
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
MIT-LICENSE
README.rdoc
Rakefile
init.rb
install.rb
uninstall.rb

README.rdoc

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