Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Extract send_draws
Browse files Browse the repository at this point in the history
  • Loading branch information
emillon committed Oct 5, 2015
1 parent 2d2041a commit c0308b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/controllers/draws_controller.rb
Expand Up @@ -19,6 +19,15 @@ def update
if order.nil?
flash[:danger] = 'Constraints could not be satisfied. You can remove some of them and try again.'
else
send_draws(order)
flash[:success] = 'Ballots have been drawn and emails sent.'
end
redirect_to @event
end

private

def send_draws(order)
for (giver, receiver) in order
draw = Draw.new(giver: giver, receiver: receiver)
@event.draws << draw
Expand All @@ -27,8 +36,5 @@ def update
for draw in @event.draws
draw.send_email
end
flash[:success] = 'Ballots have been drawn and emails sent.'
end
redirect_to @event
end
end

0 comments on commit c0308b6

Please sign in to comment.