是否可以在確認后添加閃存消息的鏈接? - Is it possible to add link to the flash message when it's confirmed? -开发者知识库

是否可以在確認后添加閃存消息的鏈接? - Is it possible to add link to the flash message when it's confirmed? -开发者知识库,第1张

I'm using Devise.
When the user succeeded at confirmation, the flash message appears.
I'd like to add a link to it.

我正在使用Devise。當用戶成功確認時,將顯示flash消息。我想添加一個鏈接。

So I want this message instead

所以我想要這條消息

Your account was successfully confirmed. You are now signed in. Go to your profile page, and edit it!

您的帳戶已成功確認。您現在已登錄。轉到您的個人資料頁面,然后進行編輯!

Then the part of profile should be the link to example.com/users/username/edit

然后,配置文件的一部分應該是example.com/users/username/edit的鏈接

How can I make it possible?

我怎樣才能成功呢?

devise.en.yml

devise.en.yml

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

2 个解决方案

#1


4  

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:

我無法實施這些解決方案。我只需要一個簡單的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 %>

And in my controller, I just entered HTML directly and without .html_safe. Works a treat!

在我的控制器中,我只是直接輸入HTML而沒有.html_safe。干得好吃!

flash[:notice] = %Q[Please <a href="#">click here</a>]

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复