summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorankonym <ankonym@gmail.com>2015-10-02 20:58:29 +0200
committerankonym <ankonym@gmail.com>2015-10-02 20:58:29 +0200
commit6f09343e85ab23c4d81f827bbd47a720f3e2cf7b (patch)
tree0b0cdcdf0646f09a8d17baf9199e993b3151b188 /lib/tasks
parent82a33300818dd8f6e06856944fe7c658746efca1 (diff)
Update rake task to allow generation of multi-use invites
The rake task now takes a second (optional) argument that sets the number of uses per invite code. If this is omitted, the default number of uses is 1. (This commit also contains some minor code cleanup that removes some stuff that I'd commented out but not removed.)
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/invite_code.rake21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/tasks/invite_code.rake b/lib/tasks/invite_code.rake
index f3bafac..6623640 100644
--- a/lib/tasks/invite_code.rake
+++ b/lib/tasks/invite_code.rake
@@ -1,16 +1,25 @@
desc "Generate a batch of invite codes"
-task :generate_invites, [:n] => :environment do |task, args|
+task :generate_invites, [:n, :u] => :environment do |task, args|
- codes = args.n
- codes = codes.to_i
+ codes = args.n
+ codes = codes.to_i
- codes.times do |x|
+ if args.u == nil
+ max_uses = 1
+
+ elsif
+ max_uses = args.u
+ max_uses = max_uses.to_i
+ end
+
+ codes.times do |x|
x = InviteCode.new
+ x.invite_max_uses = max_uses
x.save
- puts "#{x.invite_code} Code generated."
-
+ puts "#{x.invite_code} Code generated with #{x.invite_max_uses} uses."
end
+
end