Merge pull request #3792 from consul/rubocop_find_by

Apply rubocop FindBy rules
This commit is contained in:
Javier Martín
2019-10-24 16:47:21 +02:00
committed by GitHub
29 changed files with 43 additions and 40 deletions

View File

@@ -22,11 +22,11 @@ class Poll::Ballot < ApplicationRecord
end
def ballot
Budget::Ballot.where(poll_ballot: self).first
Budget::Ballot.find_by(poll_ballot: self)
end
def find_investment(investment_id)
ballot.budget.investments.where(id: investment_id).first
ballot.budget.investments.find_by(id: investment_id)
end
def not_already_added?(investment)

View File

@@ -23,7 +23,7 @@ class Poll
end
def assignment_on_poll(poll)
booth_assignments.where(poll: poll).first
booth_assignments.find_by(poll: poll)
end
end
end

View File

@@ -56,7 +56,7 @@ class Poll
def fill_stats_fields
if in_census?
self.gender = census_api_response.gender
self.geozone_id = Geozone.select(:id).where(census_code: census_api_response.district_code).first&.id
self.geozone_id = Geozone.select(:id).find_by(census_code: census_api_response.district_code)&.id
self.age = voter_age(census_api_response.date_of_birth)
end
end