Apply Rails/FindBy rubocop rule

We were already using it in most places.
This commit is contained in:
Javi Martín
2019-10-20 16:57:25 +02:00
parent 794857c31c
commit 93c6347b45
18 changed files with 27 additions and 28 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