2012-07-18 90 views
0

今天,我已經開始在驗證上遇到一個奇怪的問題。Rails:errors.add顯示HTML標籤

這是代碼。

self.errors.add("", 'Must confirm your current password to set a new one') 

但我在輸出HTML標記。如下所示。

<div id="errorList" class="errorList"><div class="errorListInner"><h5>1 error prohibited saving your profile</h5><ul><li> Must confirm your current password to set a new one</li></ul></div></div> 

我認爲CSS沒有得到應用。我正在使用rails 3.1.3和ruby 1.9.2。

任何人都可以幫助我。

在此先感謝。

回答

0

找到了一個簡單的修復答案。

不要對模型做任何事情。只需在您的「原始」查看這些錯誤正在填充的位置。

<%= raw a_helper_function_for_errors %>