mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-13 15:40:00 +01:00
Use ActiveRecord.find instead of dynamic methods
This commit is contained in:
parent
15f2c9f0cb
commit
754335143b
1 changed files with 3 additions and 5 deletions
|
@ -50,20 +50,18 @@ module UseCase
|
||||||
::Report.create(type: "Reports::#{object.class}", target_id: object.id, user_id: reporter.id, target_user_id: target_user&.id, reason: reason)
|
::Report.create(type: "Reports::#{object.class}", target_id: object.id, user_id: reporter.id, target_user_id: target_user&.id, reason: reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Rails/DynamicFindBy
|
|
||||||
def object
|
def object
|
||||||
@object ||= case object_type.strip.capitalize
|
@object ||= case object_type.strip.capitalize
|
||||||
when "User"
|
when "User"
|
||||||
::User.find_by_screen_name!(object_id)
|
::User.find_by_screen_name!(object_id)
|
||||||
when "Question"
|
when "Question"
|
||||||
::Question.find_by_id(object_id)
|
::Question.find(object_id)
|
||||||
when "Answer"
|
when "Answer"
|
||||||
::Answer.find_by_id(object_id)
|
::Answer.find(object_id)
|
||||||
when "Comment"
|
when "Comment"
|
||||||
::Comment.find_by_id(object_id)
|
::Comment.find(object_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable Rails/DynamicFindBy
|
|
||||||
|
|
||||||
def reporter
|
def reporter
|
||||||
@reporter ||= ::User.find(reporter_id)
|
@reporter ||= ::User.find(reporter_id)
|
||||||
|
|
Loading…
Reference in a new issue