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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Tim Shaffer at Oct 25, 2011 at 6:37 pm
    error.full_messages does indeed call human_attribute_name.

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

    http://ar.rubyonrails.org/classes/ActiveRecord/Errors.html#M000311

    full_messages << @base.class.human_attribute_name(attr) + " " + msg

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/VS02Sjms5v4J.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 25, '11 at 1:51p
activeOct 25, '11 at 6:37p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

iGbanam: 1 post Tim Shaffer: 1 post

People

Translate

site design / logo © 2021 Grokbase