Customizing errors

5 views
Skip to first unread message

iGbanam

unread,
Oct 25, 2011, 9:51:29 AM10/25/11
to Ruby on Rails: Talk
Hello fellow Rails devs,

I had a slight problem with validation messages. I had a Post AR model
that has an :author_name attribute.

Now if a validation goes wrong, I would like the message to say: "Name
of author can't be blank" as opposed to "author name can't be blank".

I have tried looking into the Rails Guides for I18n #5 but it seems
error.full_messages does not call human_attribute_name on the
attribute before rendering the message. So I created a workaround
which I have shared http://igbanam.wordpress.com/2011/10/25/customizing-error-messages-in-rails/

Comments and constructive criticisms please.

Tim Shaffer

unread,
Oct 25, 2011, 2:37:12 PM10/25/11
to rubyonra...@googlegroups.com
error.full_messages does indeed call human_attribute_name.

Did you check the source for that method in the link you posted?


full_messages << @base.class.human_attribute_name(attr) + " " + msg
Reply all
Reply to author
Forward
0 new messages