retrospring/app/helpers/moderation_helper.rb
Georg Gadinger 66efa5d4f4 clean up routes
- replace `match` with `get`/`post`/`patch`/`delete`
- format routes.rb
- rename the `show_user_{profile,question,answer}` routes to
  `profile`, `question`, `answer` so `url_for` (used by Rails Admin)
  works fine for these things
- also add `to_param` to the `User` model so that `url_for(some_user)`
  uses the user name
2022-07-23 12:14:06 +02:00

18 lines
472 B
Ruby

module ModerationHelper
# @param report [Report]
def content_url(report)
target = report.target
case report.type
when 'Reports::Answer'
answer_path target.user.screen_name, target.id
when 'Reports::Comment'
answer_path target.answer.user.screen_name, target.answer.id
when 'Reports::Question'
question_path 'user', target.id
when 'Reports::User'
user_path target
else
'#'
end
end
end