在闪存通知轨控制器中添加外部链接

时间:2018-04-21 06:08:56

标签: html ruby-on-rails controller

我知道这很简单,但我需要在rails控制器闪存通知中添加外部链接。现在我有这个

redirect_to root_path, flash[:success] = "Complete this quick survey. <a href='#{'http://google.com'}'>Click here</a>".html_safe

我一直收到错误

TypeError (no implicit conversion of Symbol into String):

正确的语法是什么?

我正在使用ruby 2.2.1p85&amp; Rails 4.0.10

1 个答案:

答案 0 :(得分:0)

没有插值就试试。它会起作用。

redirect_to root_path, flash[:success] = "Complete this quick survey. <a href='https://www.google.com'>Click here</a>".html_safe

或者如果你想插入:

url = "https://www.google.com"
redirect_to root_path, flash[:success] = "Complete this quick survey. <a href='#{url}'>Click here</a>".html_safe