diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/invite_code.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/invite_code.rb b/app/models/invite_code.rb index 751b28e..d52436f 100644 --- a/app/models/invite_code.rb +++ b/app/models/invite_code.rb @@ -1,10 +1,19 @@ +require 'coupon_code' + class InviteCode < CouchRest::Model::Base use_database 'invite_codes' - property :invite_code, String + property :invite_code, String, :read_only => true timestamps! design do view :by_invite_code end + + def initialize(attributes = {}, options = {}) + super(attributes, options) + write_attribute('invite_code', CouponCode.generate) if new? + end + end + |