I know this is simple but I need to add an external link to a rails controller flash notice. 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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.