diff --git a/views/votes_edit.erb b/views/votes_edit.erb index b57d28b..e7fa5f6 100644 --- a/views/votes_edit.erb +++ b/views/votes_edit.erb @@ -57,7 +57,12 @@

<%= _("Actions for organizers") %>

+ <% if @vote.candidates.length < 2 %> + +

<%= _("Add at least 2 candidates before opening the vote to participants.") %>

+ <% else %> + <% end %>
diff --git a/vote.rb b/vote.rb index 71f7f01..ce08320 100644 --- a/vote.rb +++ b/vote.rb @@ -200,8 +200,10 @@ post '/votes/:id/open' do find_vote require_organizer require_draft_vote - @vote.state = 'open' - @vote.save + if not @vote.candidates.length < 2 + @vote.state = 'open' + @vote.save + end redirect '/votes/' + @vote.secure_id end