diff options
author | ankonym <ankonym@gmail.com> | 2015-10-08 15:37:27 +0200 |
---|---|---|
committer | ankonym <ankonym@gmail.com> | 2015-10-13 11:46:02 +0200 |
commit | 76cc852527a117e1cbff7f2ea80afa9033abb422 (patch) | |
tree | a7f017c06369e4374483a43726880273547a3eb0 /lib/tasks | |
parent | 70073b1ac48f96d3e375630fb7f3904351e0f696 (diff) |
Adjust the rake task to make id = invite code
This will simplify invite code deletion after running tests.
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/invite_code.rake | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/tasks/invite_code.rake b/lib/tasks/invite_code.rake index f3bafac..b379d3a 100644 --- a/lib/tasks/invite_code.rake +++ b/lib/tasks/invite_code.rake @@ -1,16 +1,21 @@ - +require 'base64' +require 'securerandom' 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 + if args.u != nil + max_uses = args.u + end - codes.times do |x| + codes.times do |x| x = InviteCode.new + x.max_uses = max_uses x.save - puts "#{x.invite_code} Code generated." - + puts x.invite_code end -end +end |