gpt4 book ai didi

ruby-on-rails - 确认后是否可以添加到 Flash 消息的链接?

转载 作者:行者123 更新时间:2023-12-04 06:15:23 25 4
gpt4 key购买 nike

我正在使用设计。
当用户成功确认时,会出现闪现消息。
我想添加一个链接。

所以我想要这条消息
Your account was successfully confirmed. You are now signed in. Go to your profile page, and edit it!
然后是profile的部分应该是 example.com/users/username/edit 的链接

我怎样才能使它成为可能?

devise.en.yml

confirmations:
confirmed: 'Your account was successfully confirmed. You are now signed in.'

最佳答案

我在实现这些解决方案时遇到了麻烦。我所需要的只是一个简单的 HTML 链接。这是我在 Rails 4.1 中实现它的方式。我只需要清理 app/views/shared/_flash.html.erb 中的 Flash 消息:

<% flash.each do |name, msg| %>
<div class="alert alert-<%= name %>">
<a class="close" data-dismiss="alert">&#215</a>
<% if msg.is_a?(String) %>
<div id="flash_<%= name %>"> <%= sanitize(msg) %> </div>
<% end %>
</div>
<% end %>

在我的 Controller 中,我直接输入了 HTML,没有 .html_safe。很好用!
flash[:notice] = %Q[Please <a href="#">click here</a>]

关于ruby-on-rails - 确认后是否可以添加到 Flash 消息的链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15597121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com