Handle the edge case of having no votes cast yet

This commit is contained in:
Petko Bordjukov 2016-10-11 03:51:19 +03:00
parent 257793651e
commit 858ec0f548
1 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,7 @@ class Conference < ActiveRecord::Base
end
def has_vote_results?
vote_data_updated_at.present?
vote_data_updated_at.present? and number_of_ballots_cast > 0
end
def has_voting_endpoint?
@ -77,7 +77,7 @@ class Conference < ActiveRecord::Base
def save
conference.transaction do
conference.update number_of_ballots_cast: number_of_ballots
conference.number_of_ballots_cast = number_of_ballots
ranking.all?(&:save) or raise ActiveRecord::Rollback
conference.touch :vote_data_updated_at
conference.save or raise ActiveRecord::Rollback