[José, Mateo, I’ll move this to the list]
Ok, so we’ve had this short non-discussion on rails-core
It seems that Rails 3 validation error messages will be back to the
state of pre 2.3.3 at least for a short period of time. Unfortunately
nobody from rails core seems to back any of the decision options up so
the decision to break AR full_messages etc might “just happen” and we’ll
get some extra fire over here.
On the other hand this gives us the opportunity to start over with a
clean solution from scratch, implement it and get it hammered in
plugin-land and only move it to Rails after we know what we’re doing.
I’ve thus started to draft my ideas about this in code:
http://github.com/svenfuchs/messages_proposal
I’ve tried to separate all debatable “features” into optional modules.
That doesn’t mean these absolutely must be optional in Rails in the end
(even though I’d think it would be a good idea).
Enjoy and let me know what you think!
Here’s a copy of the readme:
Proposal: validation error messages in ActiveModel
This stuff is a very rough draft of how I propose to deal with
validation
error messages (and potentially other usecases that need I18n support,
such as
form labels).
It might go into Rails or end up in some plugin or gem.
I’m not looking so much at the actual integration to ActiveModel, yet.
So far
I’m just trying to sketch out the underlying stuff so that it covers all
requirements in a consistent way.
I want this stuff to be re-usable in other places where similar patterns
occur
when it comes to I18n, such as form labels and potentially other stuff.
Requirements:
- Strings in class method calls should be treated as plain text by
default
(might optionally want to treat them as translation keys for
gettext-style
class method calls if requested by the user). - Symbols in class method calls should be treated as translation keys.
- Use values from class method calls consistently with translation keys
that
are implicitly built for a validation. - Different translation variants (such as :full_message) for the same
message
should be possible. - Translation calls should optionally be able to cascade over scopes if
requested by the user. - Support format strings, e.g. “{{attribute}} {{message}}”
See the tests, especially active_model_test.rb