Ruby on rails Rails html_重定向时的安全注意事项

Ruby on rails Rails html_重定向时的安全注意事项,ruby-on-rails,ruby,Ruby On Rails,Ruby,我正试图在我的通知中添加图标,使它们更人性化。但是,浏览器将其呈现为纯文本。我怀疑这与机架和闪存消息有关 以下是我的控制器中的代码: redirect_to billing_index_path, notice: "<i class='lnr lnr-checkmark-circle'></i> Payment method updated successfully!".html_safe 重定向到计费索引路径, 注意:“付款方式已成功更新!”.html\u sa

我正试图在我的通知中添加图标,使它们更人性化。但是,浏览器将其呈现为纯文本。我怀疑这与机架和闪存消息有关

以下是我的控制器中的代码:

redirect_to billing_index_path, 
  notice: "<i class='lnr lnr-checkmark-circle'></i> Payment method updated successfully!".html_safe
重定向到计费索引路径,
注意:“付款方式已成功更新!”.html\u safe
我还尝试了
注意:(“我的字符串”).html\u safe
和raw不使用字符串
注意:(“我的字符串”).raw


问题--如何将字符串呈现为html?

我过去曾这样做过。我将原始或html_安全地移动到视图中

<% if flash[:notice].present? %>
  <div class='alert alert-info'>
    <%= raw flash[:notice] %>
  </div>
<% end %>


我希望这能有所帮助:)

我过去也这样做过。我将原始或html_安全地移动到视图中

<% if flash[:notice].present? %>
  <div class='alert alert-info'>
    <%= raw flash[:notice] %>
  </div>
<% end %>


我希望这有帮助:)

这不是一个有效的html代码,它只是一个包含html代码的字符串。它不是一个有效的html代码,它只是一个包含html代码的字符串。