Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby
Branch: master

updating README

git-svn-id: http://thmadb.com/public_svn/plugins/acts_as_tokenizable@253 6dbbdfbd-06da-443d-8068-b1bdd22a71ef
latest commit fc3c23643d
smt authored
Failed to load latest commit information.
lib changes to update the token on change
spec changes to update the token on change
README updating README
init.rb adding acts_as_tokenizable plugin

README

ActsAsTokenizable
=================

Add a column named 'token' to your model, as a string:

class AddTokenStringColumnToUsers < ActiveRecord::Migration
  def self.up
    add_column :users, :token, :string
  end

  def self.down
    remove_column :users, :token
  end
end

Then open up your class, and add the following:

class User < ActiveRecord::Base
  acts_as_tokenizable
end

Now when a user gets created, he will have a unique 16 character token:

user = User.create!
user.token # => "3737edeca0f85e76" 

By default, the token will only be updated once - on the first save.  If you would like the token
to change after every save, you may specify that like so:

class User < ActiveRecord::Base
  acts_as_tokenizable :update_token => false
end
Something went wrong with that request. Please try again.