我的项目中有一个这样的控制器:
class BriefcasesController < ApplicationController
...
def update
@super_power = SuperPower.find(params[:super_power_id])
@briefcase.contents.delete(params[:super_power_id].to_s)
flash[:notice] = "Successfully removed #{view_context.link_to(@super_power.title, super_power_path(@super_power)} from your briefcase."
redirect_back(fallback_location: '/briefcase'
end
end
帮助程序没有呈现到浏览器的link_to
链接,而是打印 html:Successfully removed <a href=\"/powers/1\>flying</a> from your briefcase.
我也尝试过使用#html_safe
flash 消息上的方法,但无济于事。我想知道是否有解决此问题的方法,view_context
或者是否有更好的方法在 Flash 消息中包含链接。