开发者

Accessing Rails Form Errors in rails 2.x

Is there a way to access form errors in the controller? In the view I can access form errors using

from.error_messages

I want to list errors in a flash message before may layout header, how do I 开发者_运维技巧go about accessing those errors in the controller so I can assign them to a flash message?


@model_instance.errors.full_messages.to_sentence


You may find error_messages_for and similar methods to be more convenient way to display errors in another place. More details here:
http://guides.rubyonrails.org/activerecord_validations_callbacks.html#displaying-validation-errors-in-the-view

What you want well may be already supported, as it's often the case with rails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜