Wolfram Arnold, RubyFocus
2011-Jan-10 22:40 UTC
Functionality reduction? How to customize full_message for validation error using i18n in Rails 3?
Folks, I just posted a bug report about this: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6274-ability-to-specify-a-custom-translation-for-full_messages-gone-in-rails-3x The more I think about this, the more puzzled I am as to what the new convention for Rails 3 is to override a validation error that doesn''t fit into the "%{attribute} %{message}" format that the current framework imposes. In Rails 2.3, it was possible to override the :full_message on a per- attribute basis through i18N, in em.yml. I can''t find any documentation or even discussion about it. The only vague reference is a thread from a year ago by Rodrigo Rosenfeld Rosas to override the full_message as a validation parameter, but that didn''t fly either. Concretely, given code like this: errors.add(:credit_card_number, :authentication_failure) I want to be able to have a custom message that doesn''t start with the attribute name. I do want to add the error to the attribute, however, so that the correct form field gets highlighted. I''d be most grateful if anyone could point me in the right direction, if I overlooked something, or confirm that this was removed from Rails 2.3.x Thanks, Wolf -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Rodrigo Rosenfeld Rosas
2011-Jan-12 10:44 UTC
Re: Functionality reduction? How to customize full_message for validation error using i18n in Rails 3?
How about this approach? https://rails.lighthouseapp.com/projects/8994/tickets/3768-patch-add-full_message-option-to-validations Rodrigo. On 10-01-2011 20:40, Wolfram Arnold, RubyFocus wrote:> Folks, > > I just posted a bug report about this: > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6274-ability-to-specify-a-custom-translation-for-full_messages-gone-in-rails-3x > > The more I think about this, the more puzzled I am as to what the new > convention for Rails 3 is to override a validation error that doesn''t > fit into the "%{attribute} %{message}" format that the current > framework imposes. > > In Rails 2.3, it was possible to override the :full_message on a per- > attribute basis through i18N, in em.yml. I can''t find any > documentation or even discussion about it. The only vague reference is > a thread from a year ago by Rodrigo Rosenfeld Rosas to override the > full_message as a validation parameter, but that didn''t fly either. > > Concretely, given code like this: > > errors.add(:credit_card_number, :authentication_failure) > > I want to be able to have a custom message that doesn''t start with the > attribute name. I do want to add the error to the attribute, however, > so that the correct form field gets highlighted. I''d be most grateful > if anyone could point me in the right direction, if I overlooked > something, or confirm that this was removed from Rails 2.3.x > > Thanks, > > Wolf >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.