Giter Site home page Giter Site logo

justinsaul / acts_as_redeemable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cyu/acts_as_redeemable

1.0 2.0 1.0 102 KB

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

Home Page: http://squeejee.com

License: MIT License

Ruby 100.00%

acts_as_redeemable's Introduction

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

acts_as_redeemable's People

Contributors

cyu avatar justinsaul avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

dcalixto

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.