[英]Adding an External link in flash notice rails controller
I know this is simple but I need to add an external link to a rails controller flash notice. 我知道这很简单,但是我需要向Rails控制器Flash通知中添加一个外部链接。 Right now I have this 现在我有这个
redirect_to root_path, flash[:success] = "Complete this quick survey. <a href='#{'http://google.com'}'>Click here</a>".html_safe
And I keep getting the error 而且我不断收到错误
TypeError (no implicit conversion of Symbol into String):
What is the proper syntax? 正确的语法是什么?
I am using ruby 2.2.1p85 & Rails 4.0.10 我正在使用ruby 2.2.1p85和Rails 4.0.10
Try it without the interpolation.It will work. 尝试不使用插值的方法。它将起作用。
redirect_to root_path, flash[:success] = "Complete this quick survey. <a href='https://www.google.com'>Click here</a>".html_safe
or if you want to interpolate: 或如果要插值:
url = "https://www.google.com"
redirect_to root_path, flash[:success] = "Complete this quick survey. <a href='#{url}'>Click here</a>".html_safe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.