您采用什么方法将链接嵌入到Flash消息中? [英] What approach do you take for embedding links in flash messages?
问题描述
从用户交互的角度来看,具有包含嵌入式链接的Flash消息(通知,错误,警告等)的功能很好.但是,将锚标记嵌入到来自控制器的Flash消息中是肮脏的.
The ability to have flash messages (notice, error, warning, etc) with embedded links is nice from a user interaction standpoint. However, embedding an anchor tag inside a flash message from the controller is dirty.
让我们假设这样的即插即用消息对可用性*很有帮助:
Let's assume that a flash message like this is good for usability*:
带有嵌入式链接的Flash消息示例示例http://img.skitch.com/20090826- xbsa4tb3sjq4fig9nmatakthx3.png (从 DailyMile.com 借来)
Example Flash Message Notice with an Embedded Link http://img.skitch.com/20090826-xbsa4tb3sjq4fig9nmatakthx3.png (borrowed from DailyMile.com)
您将在控制器和视图之间采取什么策略来干净利落地采用这种方法?
推荐答案
我只是想分享一下,因为找到了答案,所以我正在其他地方寻找
Just thought I would share this, since found answer I was looking for elsewhere:
在Rails 3.1上工作
Works on rails 3.1
flash[:notice] = "Proceed to #{view_context.link_to('login page', login_path)}".html_safe
这篇关于您采用什么方法将链接嵌入到Flash消息中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!