forked from gumayunov/custom-err-msg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
executable file
·36 lines (22 loc) · 1.16 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Custom Error Message
====================
This plugin gives you the option to not have your custom validation error message
prefixed with the attribute name. Ordinarily, if you have, say:
validates_acceptance_of :accepted_terms, :message => 'Please accept the terms of service'
You'll get the following error message:
Accepted terms Please accept the terms of service
This plugin allows you to omit the attribute name for specific messages. All you have to do
is begin the message with a '^' character. Example:
validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'
The plugin also lets you use procs instead of strings. Example:
validates_acceptance_of :accepted_terms, :message => Proc.new {|service| "You must accept the terms of the service #{service.name}" }'
Detail
------
Redefines method:
ActiveRecord::Errors::full_messages
Returns all the full error messages in an array. 'Base' messages are handled as usual.
Non-base messages are prefixed with the attribute name as usual UNLESS they begin with '^'
in which case the attribute name is omitted.
Source
------
http://github.com/gumayunov/custom-err-msg/tree