-
In your
Gemfile
gem 'plymouthsoftware-core', :git => 'git://github.com/plymouthsoftware/core.git''
-
Install with Bundler:
$ bundle install
-
Create a User model:
$ rails generate model user first_name:string last_name:string email:string password_hash:string password_digest:string verified:boolean active:boolean verification_token:string $ rake db:migrate
-
In your model:
class User < ActiveRecord::Base is_user end
u = User.new
u.name = "Joe Bloggs"
u.email = "joe@example.com"
u.password = "secret"
u.active = true
u.save
u.first_name
# => "Joe"
u.last_name
# => "Joe"
u.active?
# => true
u.verified?
# => false
u.verify!
# => true (verification_token is nil by default)
User.verified.active
# => [<User: (Joe Bloggs)>, ...]
User.authenticate_with_email_and_password("joe@example.com", "oops")
# => nil
User.authenticate_with_email_and_password("joe@example.com", "secret")
# => <User: (Joe Bloggs)>