Handle the edge case of having no votes cast yet
This commit is contained in:
parent
257793651e
commit
858ec0f548
|
@ -41,7 +41,7 @@ class Conference < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_vote_results?
|
def has_vote_results?
|
||||||
vote_data_updated_at.present?
|
vote_data_updated_at.present? and number_of_ballots_cast > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_voting_endpoint?
|
def has_voting_endpoint?
|
||||||
|
@ -77,7 +77,7 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
def save
|
def save
|
||||||
conference.transaction do
|
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
|
ranking.all?(&:save) or raise ActiveRecord::Rollback
|
||||||
conference.touch :vote_data_updated_at
|
conference.touch :vote_data_updated_at
|
||||||
conference.save or raise ActiveRecord::Rollback
|
conference.save or raise ActiveRecord::Rollback
|
||||||
|
|
Loading…
Reference in New Issue