我在applicationhelper中写了一个helper方法,比如这个
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"> <div class="errors">username is wrong</div>
有什么帮助吗? THX!
答案 0 :(得分:2)
str = f.text_field(:username) + "<div class='error'>username is wrong </div>".html_safe