From 6dba1392a29a003c3334259a222061f29ff04b13 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 14 Jan 2016 16:14:39 -0800 Subject: added UI for invite codes --- app/models/invite_code.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'app/models') 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 -- cgit v1.2.3