有没有办法在控制器内部使用link_to标签?

问题描述

我想在控制器内使用link_to标记。 我添加include ActionView::Helpers::UrlHelper,这是我的代码

def authenticate_user!
    unless user_signed_in?
        flash[:danger] ="You must sign in or sign up first!#{link_to("test",root_path) }".html_safe
        redirect_to new_session_path
    end
end

如果我转到浏览器,它将显示You must sign in or sign up first!<a href="/">test</a>

您知道如何正确显示此消息吗? (我的意思是没有标签

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)