mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-13 14:59:59 +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)
|
||||
end
|
||||
|
||||
# rubocop:disable Rails/DynamicFindBy
|
||||
def object
|
||||
@object ||= case object_type.strip.capitalize
|
||||
when "User"
|
||||
::User.find_by_screen_name!(object_id)
|
||||
when "Question"
|
||||
::Question.find_by_id(object_id)
|
||||
::Question.find(object_id)
|
||||
when "Answer"
|
||||
::Answer.find_by_id(object_id)
|
||||
::Answer.find(object_id)
|
||||
when "Comment"
|
||||
::Comment.find_by_id(object_id)
|
||||
::Comment.find(object_id)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Rails/DynamicFindBy
|
||||
|
||||
def reporter
|
||||
@reporter ||= ::User.find(reporter_id)
|
||||
|
|
Loading…
Reference in a new issue