当确认消息时,是否可以添加Flash消息的链接? [英] Is it possible to add link to the flash message when it's confirmed?
问题描述
我正在使用Devise。
当用户成功确认时,会出现闪光消息。
我想添加一个链接。
I'm using Devise.
When the user succeeded at confirmation, the flash message appears.
I'd like to add a link to it.
所以我想要这个消息
您的帐户已成功确认。您现在已经登录了,请前往您的个人资料页面进行编辑!
然后, / code>应该是链接到
example.com/users/username/edit
如何我有可能吗?
devise.en.yml
confirmations:
confirmed: 'Your account was successfully confirmed. You are now signed in.'
推荐答案
这些解决方案。我需要的只是Flash中的一个简单的HTML链接。这是我如何在Rails 4.1中实现的。我只需要在app / views / shared / _flash.html.erb中清理Flash消息:
I had trouble implementing these solutions. All I needed was a simple HTML link in the flash. Here's how I implemented it in Rails 4.1. I just had to sanitize my flash messages in app/views/shared/_flash.html.erb:
<% flash.each do |name, msg| %>
<div class="alert alert-<%= name %>">
<a class="close" data-dismiss="alert">×</a>
<% if msg.is_a?(String) %>
<div id="flash_<%= name %>"> <%= sanitize(msg) %> </div>
<% end %>
</div>
<% end %>
在我的控制器中,我直接输入HTML,没有.html_safe。作为一个对待!
And in my controller, I just entered HTML directly and without .html_safe. Works a treat!
flash[:notice] = %Q[Please <a href="#">click here</a>]
这篇关于当确认消息时,是否可以添加Flash消息的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!