0

ajax 调用的当前代码:

@return = { :error => true, :response => @invitation.errors.full_messages.join("<br />") }

错误现在显示为

Email can't be blank
Email is invalid

如何在每行中添加div错误消息和p标签?

所以它会变成

<div>
    <p>Email can't be blank</p>
    <p>Email is invalid</p>
</div>
4

1 回答 1

3

像这样的东西可能对你有用:

error_message = content_tag :div, @invitation.errors.full_messages.map {|error| "<p>#{error}</p>"}.join
@return = { :error => true, :response => error_message }
于 2012-07-25T16:11:58.427 回答