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

@@ -36,7 +36,7 @@ class Signature < ApplicationRecord
end
def assign_signature_to_vote
vote = Vote.where(votable: signable, voter: user).first
vote = Vote.find_by(votable: signable, voter: user)
vote&.update!(signature: self)
end
@@ -55,7 +55,7 @@ class Signature < ApplicationRecord
email: nil,
date_of_birth: @census_api_response.date_of_birth,
gender: @census_api_response.gender,
geozone: Geozone.where(census_code: @census_api_response.district_code).first
geozone: Geozone.find_by(census_code: @census_api_response.district_code)
}
User.create!(user_params)
end
@@ -84,7 +84,7 @@ class Signature < ApplicationRecord
end
def set_user
user = User.where(document_number: document_number).first
user = User.find_by(document_number: document_number)
update(user: user)
end