Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 813 Bytes

README.textile

File metadata and controls

33 lines (22 loc) · 813 Bytes

ActsAsRedeemable

Adds redemption capability to a model for items like coupons, invitation codes, etc. Each redeemable gets a unique code upon creation that can be sent in an email or printed as a coupon code.

Usage

Optionally generate the model

script/generate redeemable Coupon rake db:migrate

Make your ActiveRecord model act as redeemable.

class Coupon < ActiveRecord::Base
acts_as_redeemable :valid_for => 30.days, :code_length => 8 # optional expiration, code length
end

Create a new instance


c = Coupon.new
c.user_id = 1 # The user who created the coupon 
c.save
c.code 
# "4D9110A3"
c.created_at  
# Fri Feb 15 14:56:37 -0600 2008
c.expires_on 
# Fri Mar 16 14:56:37 -0600 2008 

Copyright © 2008 Squeejee, released under the MIT license