Skip to content

Displaying ActiveResource errors

January 4, 2011

Being a Rails newbie, I was pleased to learn that errors returned from an ActiveResource object can be displayed in exactly the same way as for an ActiveResource object, e.g:

<%= error_messages_for 'account' %>

Even better is to do something like the following:

<%= error_messages_for 'account',
:header_message => "We couldn't update your billing information.",
:message => "The following fields were problematic:",
:header_tag => :h2 %>

which removes that terse “X errors prohibited this Y from being saved” and formats things a bit more nicely.

Reference: http://apidock.com/rails/ActionView/Helpers/ActiveRecordHelper/error_messages_for

Advertisements

From → rails, ruby

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: