Forum: Ruby on Rails Validation messages

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
LeonB (Guest)
on 2007-03-19 01:19
(Received via mailing list)
Hi,

I'm developing a dutch ruby on rails application. So I want the error
messages to be in dutch. But when I add: ":message => 'Geen wachtwoord
ingevuld' " to the user model I get this error message:

" Password Geen wachtwoord ingevuld"

How can I remove the fieldname from the error message? So it would
say:

"Geen wachtwoord ingevuld"
Bogdan I. (Guest)
on 2007-03-19 01:33
(Received via mailing list)
you could probably do something like

validate_on_create :check_defaults
def check_defaults
errors.add("","dutch text") if self.password.length<5
end
Peter De Berdt (Guest)
on 2007-03-19 10:35
(Received via mailing list)
On 19 Mar 2007, at 00:18, LeonB wrote:

> I'm developing a dutch ruby on rails application. So I want the error
> messages to be in dutch. But when I add: ":message => 'Geen wachtwoord
> ingevuld' " to the user model I get this error message:
>
> " Password Geen wachtwoord ingevuld"
>
> How can I remove the fieldname from the error message? So it would
> say:
>
> "Geen wachtwoord ingevuld"

http://agilewebdevelopment.com/plugins/error_messages_for


Best regards

Peter De Berdt
LeonB (Guest)
on 2007-03-19 23:58
(Received via mailing list)
Thanks! Works like a charm. Maybe a bit too much for what I want. But
maybe when I get to know Ruby/Rails better I'll make one myself.
Jamal S. (Guest)
on 2007-03-20 15:53
LeonB wrote:
> Hi,
>
> I'm developing a dutch ruby on rails application. So I want the error
> messages to be in dutch. But when I add: ":message => 'Geen wachtwoord
> ingevuld' " to the user model I get this error message:
>
> " Password Geen wachtwoord ingevuld"
>
> How can I remove the fieldname from the error message? So it would
> say:
>
> "Geen wachtwoord ingevuld"

Another solution for languages thing=>

You can change the return error message by editing the
default_error_messages array hash.

Example:
ActiveRecord::Errors.default_error_messages[:taken] = "is in use"

you put this line in your environment.rb file, and the error message
will be used across all your models validation uniqueness :D
This topic is locked and can not be replied to.