Paweł Kondzior
5da6b6ed67
Fix ActiveModel::Errors#dup
...
Since ActiveModel::Errors instance keeps all error messages as hash
we should duplicate this object as well.
Previously ActiveModel::Errors was a subclass of ActiveSupport::OrderedHash,
which results in different behavior on dup, this may result in regression for
people relying on it.
Because Rails 3.2 stills supports Ruby 1.8.7 in order to properly fix this
regression we need to backport #initialize_dup.
2012-01-23 23:01:11 +01:00
Piotr Sarnacki
f34e5a7d4c
Add ActiveModel::Errors#delete, which was not available after move to use delegation
2012-01-23 23:01:11 +01:00
Vijay Dev
388f09c28b
fix misleading comment (originally made by Tate Johnson, we lost this commit while porting to the rails repo)
2011-08-16 11:10:11 -07:00
thedarkone
09dd71cbdf
Handle the empty array correctly.
2011-07-28 12:24:02 +02:00
Vijay Dev
0e8857b65e
fix incorrect output
2011-06-06 22:45:04 +02:00
Xavier Noria
3e24e9ebc2
Merge branch 'master' of git://github.com/lifo/docrails
2011-04-03 22:22:03 +02:00
Santiago Pastorino
4f90b28e06
Bring back AMo#i18n_key method
2011-03-30 16:29:43 -03:00
John Firebaugh
b671e4d86a
Fix formatting and broken markup
2011-03-28 22:31:05 -07:00
Santiago Pastorino
a00bed0c48
Revert "Properly interpolate i18n keys in modules [ #5572 state:resolved]"
...
This breaks #6448 , you should use :"module/class" as key for namespacing
[#6448 state:committed]
This reverts commit 8d30193b08 .
2011-02-27 21:30:03 -02:00
Aaron Patterson
f48d32c0cf
implementing include? on AM::Errors
2011-02-09 09:19:56 -08:00
Aaron Patterson
51d84c1d33
we do not need message to be an array
2011-02-09 08:42:13 -08:00
Aaron Patterson
c6b4ef082f
use map rather than array concatenation
2011-02-09 08:32:43 -08:00
Aaron Patterson
307e6b2b74
favor composition over inheritence
2011-02-09 08:32:43 -08:00
Aaron Patterson
ed6e09c1b1
use 1 call to concat rather than calling << n times
2011-02-09 08:32:43 -08:00
Hemant Kumar
8de5595e4d
fix difference between behaviour of blank and empty
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2011-01-05 13:18:10 +01:00
Thilo Utke
7148b933c4
ActiveModel::Errors.to_hash returns plain OrderedHash and used in to_json serialization to properly handle multiple errors per attribute [ #5615 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-12-01 11:43:37 +01:00
José Valim
1ec126dd37
Revert "Fix generation of wrong json string when field has multiple errors"
...
This reverts commit a9b666b51d .
2010-12-01 11:42:30 +01:00
Krekoten' Marjan
a9b666b51d
Fix generation of wrong json string when field has multiple errors
2010-12-01 00:03:42 +08:00
Rodrigo Rosenfeld Rosas
8d30193b08
Properly interpolate i18n keys in modules [ #5572 state:resolved]
2010-09-24 20:41:12 +02:00
José Valim
f0ee4a6002
Remove deprecations in ActiveModel.
2010-08-29 20:45:34 -03:00
Santiago Pastorino
b451de0d6d
Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;)
2010-08-14 04:12:33 -03:00
Xavier Noria
3cbe111439
Merge remote branch 'docrails/master'
2010-08-05 01:15:57 +02:00
Subba Rao Pasupuleti
8d9d8bc93c
Tidy up error.rb code
...
[#5288 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com >
2010-08-03 14:54:13 -03:00
Neeraj Singh
74f7e172c7
fixing documentation
2010-08-03 04:14:14 -04:00
Alex Le
aeaab06c79
ActiveModel::Errors json serialization to work as Rails 3b4 [ #5254 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-08-02 16:26:32 +02:00
Xavier Noria
755af49755
edit pass to apply API guideline wrt the use of "# =>" in example code
2010-07-30 02:30:04 +02:00
Santiago Pastorino
075f8b7241
Add a missing require to allow the usage of Array#to_xml
2010-07-03 09:59:51 -03:00
José Valim
7bd85a8fc2
Work around the fact the JSON gem was overwriting to_json implementation for all Ruby core classes.
...
This is required because the JSON gem is incompatible with Rails behavior and was not allowing ActiveModel::Errors to be serialized.
So we need to ensure Rails implementation is the one triggered. [#4890 state:resolved]
2010-06-26 12:01:13 +02:00
Josh Kalderimis
e8c064bbe0
Regression with how base errors messages are added to a model. Works correctly for both string error messages and symbol translated messages.
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-23 14:45:55 +02:00
José Valim
0421fb7a91
Refactor previous commit a bit [ #4057 state:resolved]
2010-06-21 12:17:24 +02:00
Jeroen van Dijk
26392c4ac5
Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options.
...
This makes it possible to pass additional options through Validators to message generation. E.g. plugin authors want to add validates_presence_of :foo, :format => "some format".
Also, cleanup the :default vs :message options confusion in ActiveModel validation message generation.
Also, deprecate ActiveModel::Errors#add_on_blank(attributes, custom_message) in favor of ActiveModel::Errors#add_on_blank(attributes, options).
Also, refactoring of ActiveModel and ActiveRecord Validation tests. Test are a lot more DRY now. Better test coverage as well now.
The first four points were reapplied from an older patch of Sven Fuchs which didn't apply cleanly anymore and was not complete yet.
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-21 11:55:21 +02:00
Evgeniy Dolzhenko
ef404c771d
Fix a bunch of minor spelling mistakes
2010-06-15 12:04:22 +04:00
Rizwan Reza
626586b8c7
Minor changes to active_model/errors.rb
2010-06-14 13:40:57 +04:30
Evgeniy Dolzhenko
ccf9577aee
Fix a bunch of minor spelling mistakes
2010-06-11 14:15:34 +04:00
Xavier Noria
a0bb1dda11
revises rdoc of AMo::Error#add [ #4738 state:resolved]
2010-06-01 15:44:14 +02:00
José Valim
13867a3f5f
Use %{} syntax in I18n (faster) instead of {{}}.
2010-05-01 12:54:52 +02:00
Ryan Bigg
d748cc3cd0
Re-define empty? for errors to check if the values inside the OrderedHash are empty rather than the OrderedHash itself. [ #4356 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-04-10 13:21:20 +02:00
Aaron Patterson
30f3a3df77
errors.rb needs to be declared as UTF-8 [ #3941 state:resolved]
...
Signed-off-by: wycats <wycats@gmail.com >
2010-04-02 09:14:55 -07:00
Xavier Noria
76f024ac8d
adds missing requires for Object#blank? and Object#present?
2010-03-28 14:15:02 +02:00
Jeremy Kemper
a98db7c6ef
Use Array.wrap uniformly
2010-03-27 11:50:11 -07:00
Mikel Lindsaar
a07d0f8786
Full update on ActiveModel documentation
2010-02-01 10:08:20 +11:00
José Valim
d6e2f5013c
Drop AR I18n deprecation and simple use errors.messages as fallback.
2010-01-30 13:12:12 +01:00
Samuel Elliott
31ea83eb89
Adding Proc support to validation messages so that they can become a little more dynamic, allowing for customisations during the request [ #3514 status:resolved].
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-01-17 14:40:10 +01:00
José Valim
190ce3ab37
Errors messages are now moved from :activerecord.errors to simply :errors on I18n yml files.
2010-01-07 15:31:49 +01:00
José Valim
7cc0a4cfa1
Use activerecord.errors.format as in Rails 2.3.5.
2010-01-02 22:27:02 +01:00
José Valim
5fdd0e80a4
Be sure to convert namespaced names to we have 'Parrots name' instead of 'Parrots.name' in error messages.
2010-01-02 22:27:02 +01:00
José Valim
e714b499cc
Move validator, human_name and human_attribute_name to ActiveModel, remove deprecated error messages and add i18n_scope and lookup_ancestors.
...
Signed-off-by: Carl Lerche <carllerche@mac.com >
2009-10-20 17:52:32 -07:00
Brian Donovan
f183288050
Fix typo.
...
Signed-off-by: Yehuda Katz <wycats@gmail.com >
2009-09-17 18:30:28 -07:00
Akira Matsuda
0990a13500
Ensure validation errors to be ordered in declared order
...
[#2301 state:committed milestone:2.3.5]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-09-11 18:52:22 -07:00
Pratik Naik
5ce3831faf
Use send instead of instance_eval
2009-08-06 00:11:28 +01:00