diff options
Diffstat (limited to 'app/models/invite_code.rb')
-rw-r--r-- | app/models/invite_code.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/invite_code.rb b/app/models/invite_code.rb new file mode 100644 index 0000000..30a6498 --- /dev/null +++ b/app/models/invite_code.rb @@ -0,0 +1,22 @@ +require 'coupon_code' + +class InviteCode < CouchRest::Model::Base + use_database 'invite_codes' + property :invite_code, String, :read_only => true + property :invite_count, Integer, :default => 0, :accessible => true + + timestamps! + + design do + view :by_invite_code + view :by_invite_count + end + + def initialize(attributes = {}, options = {}) + super(attributes, options) + write_attribute('invite_code', CouponCode.generate) if new? + end + +end + + |