routes: replace hardcoded routes in models with route helpers.

Add a Routes module that gives models access to route helpers outside of
views, and use it to replace various hardcoded routes.
This commit is contained in:
evazion
2020-12-23 13:19:03 -06:00
parent a947a10c53
commit dbb66ace90
13 changed files with 34 additions and 21 deletions

View File

@@ -21,7 +21,7 @@ class Comment < ApplicationRecord
mentionable(
:message_field => :body,
:title => ->(user_name) {"#{creator.name} mentioned you in a comment on post ##{post_id}"},
:body => ->(user_name) {"@#{creator.name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n"}
:body => ->(user_name) {"@#{creator.name} mentioned you in a \"comment\":#{Routes.post_path(post, anchor: "comment-#{id}")} on post ##{post_id}:\n\n[quote]\n#{DText.extract_mention(body, "@" + user_name)}\n[/quote]\n"}
)
module SearchMethods