diff options
author | elijah <elijah@riseup.net> | 2016-01-14 16:14:39 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2016-01-14 16:14:39 -0800 |
commit | 6dba1392a29a003c3334259a222061f29ff04b13 (patch) | |
tree | e3161cf87ecec5ebc095adf55f66db1e21c17cbb /app/models | |
parent | dd2518c40ab06f51d0f7380f1521087d3a4fbd5f (diff) |
added UI for invite codes
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/invite_code.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/invite_code.rb b/app/models/invite_code.rb index 5666a4f..9c6df66 100644 --- a/app/models/invite_code.rb +++ b/app/models/invite_code.rb @@ -15,13 +15,12 @@ class InviteCode < CouchRest::Model::Base end def initialize(attributes = {}, options = {}) - if !attributes.has_key?("_id") - attributes[:id] = InviteCode.generate_invite - end - + attributes[:id] = attributes["invite_code"] || InviteCode.generate_invite super(attributes, options) - - write_attribute('invite_code', attributes[:id]) if new? + if new? + write_attribute('invite_code', attributes[:id]) + write_attribute('max_uses', attributes[:max_uses] || 1) + end end def self.generate_invite |