Skip to content

Adds redemption capability to a model for items like coupons, invitation codes, etc.

License

Notifications You must be signed in to change notification settings

squeejee/acts_as_redeemable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Adds redemption capability to a model for items like coupons, invitation codes, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages