2010-08-30 42 views
1

我寫一個輔助方法在applicationhelper像這樣如何讓f.text_field + 「<div>there is a error</div>」 工作

str = f.text_field(:username) + "<div class='error'>username is wrong </div>" 

然後在我的view.rhtml它這樣表示

<input type="text" value="" size="30" name="user[username]" id="user_username">  &lt;div class="errors"&gt;username is wrong&lt;/div&gt;  

任何幫助?謝謝!

回答

2
str = f.text_field(:username) + "<div class='error'>username is wrong </div>".html_safe 
+0

謝謝艾米特,鐵軌讓我感到驚喜 – juliet 2010-08-31 02:45:45