ruby-on-rails - 有没有办法在控制器内使用 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>
您知道如何正确显示此消息吗?(我的意思是没有标签)
谢谢!
解决方案
推荐阅读
- hyperledger-fabric - Hyperledger Fabric 在现有设置中添加新排序器时出现错误:x509:ECDSA 验证失败
- python - 按纬度以 nlat/nlon 格式子集 CMIP netCDF 文件
- python - AWS Cognito、AWS APIGateway 和 Python 中的凭证
- c++ - 使用函数 c++ 插入重试功能
- angular - 如何在 ng-multiselect-dropdown 库中启用工具提示
- apache - 用于文件共享的 Apache 时区
- mobile - 移动空手道 fw 中的向下滚动方法
- spring - Eureka - Swagger 定义的分类
- reactjs - NextJS 与 next-i18next 产生错误文本内容不匹配
- tensorflow - 3D CNN 模型抛出负维度错误——维度问题