实施后
@mentions
到
Article
型号
has_rich_text
,一切都很好,但当我试图将这些文章作为电子邮件发送时,提及的内容无法正确显示。我明白了
sgid
和
content
,但html只是为
@提及
。
rails mailer预览显示一切正常,即提及渲染正确。但是,在生产中,它无法正确渲染。
编辑:
睡了一会儿,重新看了医生,我意识到
link_to
无法根据文档工作:
由于:主机通常在整个应用程序中是一致的,因此您可以
在config/application.rb中全局配置:
config.action_mailer.default_url_options = { host: 'example.com' }
由于这种行为,您不能使用任何*_path辅助对象
在电子邮件内部。相反,您需要使用关联的*_url
帮手例如,而不是使用
<%= link_to 'welcome', welcome_path %>
您需要使用:
<%= link_to 'welcome', welcome_url %>
通过使用完整的URL,您的链接现在可以在您的电子邮件中使用。
需要实施和发现,将更新。阅读文档时,似乎传入
Active Record model
不起作用:
更简洁的是,当名称是定义
tos方法返回默认值或模型实例属性
link_to @profile
# => <a href="http://www.example.com/profiles/1">Eileen</a>
因此需要提供
url
而且
有什么想法吗?为什么会这样/如何解决?
生产:
<action-text-attachment sgid="eyJfcmFpbHMiOnspJaXhuYVdRNkx5OWhjRE12VFhWelkyeGxMekUyUDJWNGNkZWQT09IiwiZXhwIjpudWxsLCJwdXIiOiJhdHRhY2hhYmxlIn19--31217260f33fc8fce3243" content-type="application/octet-stream" content="<a data-turbo-frame="_top" data-class="description" target="_blank" href="/gadgets/muscles/triceps-brachii">
Triceps Brachii
</a>">â</action-text-attachment>
正如你所看到的,这只是创建了一个“”。
开发人员:
<action-text-attachment sgid="eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaTFuYVdRNkx5OWhjR1Y0TFcxdmNuUDJsdUJqb0dSVlE9IiwiZXhwIjhdHRhY2hhYmxlIn19--391d3670aff9" content-type="application/octet-stream" content=" <a data-turbo-frame="_top" data-class="description" target="_blank" href="/gadgets/muscles/abductor-hallucis">
Abductor Hallucis
</a>"> <a href="/gadgets/muscles/abductor-hallucis">
Abductor Hallucis
</a></action-text-attachment>
它创建了
链接到
为阿卜杜勒·哈卢西斯。
用于网站呈现内部内容
ActionText
/
Trix
,我有以下内容:
_exercise_mention.html.erb:
<%= link_to exercise, data: { turbo_frame: "_top", class: "description" }, target: :_blank do %>
<%= exercise.name.humanize.titleize %>
<% end %>
_exercise_mention.jbuilder:
json.extract! exercise, :id, :name
json.sgid exercise.attachable_sgid
json.content render(partial: "exercises/exercise_mention", locals: { exercise: exercise }, formats: [:html])
Exercise model:
class Exercise < ApplicationRecord
include ActionText::Attachable
......
#show mentions Article
def to_trix_content_attachment_partial_path
"exercises/exercise_mention"
end
#edit mentions Article
def to_attachable_partial_path
"exercises/exercise_mention"
end
end