Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created December 10, 2008 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agibralter/34240 to your computer and use it in GitHub Desktop.
Save agibralter/34240 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
# ...
attr_accessor :password, :password_confirmation
attr_accessible :login, :email, :password, :password_confirmation
state_machine :state_email, :initial => 'fresh' do
before_transition :to => 'unverified', :do => :make_email_verification_code
before_transition :to => 'verified', :do => :set_email_verified_attributes
event :unverify do
transition :to => 'unverified', :from => %w(unverified verified fresh)
end
event :verify do
transition :to => 'verified', :from => %w(unverified verified fresh)
end
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment