如何在Devise Flash消息中呈现HTML和Rails助手?
我正在尝试从Devise控制器渲染自定义Flash消息。
它在视图中呈现如下:
Your profile is incomplete. Why not #{ActionController::Base.helpers.link_to 'add some more information', edit_user_registration_path}.
如何在此flash中呈现HTML和Rails助手?
我在控制器中调用闪光灯
set_flash_message :warning, :profile_incomplete
使用:profile_incomplete
config / locales / devise.en.yml中定义的:profile_incomplete
。
我尝试将字符串直接放在控制器中。 这会正确呈现帮助程序,但会显示未找到设备转换错误。
我尝试在devise.en.yml中附加.html_safe
,这会导致yaml错误。 我试过追加:profile_incomplete
导致undefined method 'html_safe' for :profile_incomplete:Symbol
。 而且我已经尝试附加到普通的字符串,它似乎没有做任何事情。
我错过了什么? 谢谢你的任何建议。
编辑
sessions_controller.rb
def after_sign_in_path_for(resource) if current_user.completeness ActionController::Base.helpers.link_to('add some more information', edit_user_registration_path) end end
devise.en.yml
en: devise: sessions: profile_incomplete:"Your profile is incomplete. Why not #{link}."
application.html.erb
<div class="alert alert-"> x