acts_as_inactive

- put objects in an inactive state and activate them with activation codes

ActsAsInactive

Place objects in an inactive state and activate them with activation codes. This is what is already done for users created by the restful_authentication plugin, but this plugin creates a seperate polymorphic table for this ability

Installation

            
              git clone git://github.com/gregwebs/acts_as_inactive.git vendor/plugins/acts_as_inactive
            
              copy vendor/plugins/acts_as_inactive/migration.rb as a new migration
            

Example

            
              class User < ActiveRecord::Base
                has_one :inactive, :as => :activation
            
                def after_create
                  Inactive.put self # => returns activation code
                  # activation code can be accessed at _self.inactive.activation_code_
                  UserMailer.deliver_signup_notification(self)
                end
            
                def self.activate aCode
                  # _User_ is an optional type check
                  # block is optional, object will not be activated if block returns false
                  Inactive.activate(aCode, User) do |u|
                    u.activated_at = Time.now.utc
                    u.save
                  end
                end
              end
            

Copyright (c) 2008 Greg Weber gregweber.info, released under the MIT license

Homepage

projects.gregweber.info/acts_as_inactive