summaryrefslogtreecommitdiff
path: root/lib/tasks/invite_code.rake
blob: 662364005561a7fb4a1931ee1255a69d175eff21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


desc "Generate a batch of invite codes"
task :generate_invites, [:n, :u] => :environment do |task, args|

  codes = args.n
  codes = codes.to_i

  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 with #{x.invite_max_uses} uses."
  end

end