Commit Graph

28 Commits

Author SHA1 Message Date
Raimonds Simanovskis
070c9984a5 Do not use SQL LIKE operator for case insensitive uniqueness validation
It can result in wrong results if values contain special % or _ characters. It is safer to use SQL LOWER function and compare for equality.
2011-04-25 22:17:18 +03:00
Aaron Patterson
c4fc396300 adding a case_sensitive_modifier for forcing comparisons to be case sensitive 2011-04-11 10:02:39 -07:00
Brian Cardarella
a30b440deb Refactored uniqueness validator to use Arel instead of hardcoded SQL 2011-04-10 21:28:12 -07:00
Anders Elfving
9b64399684 Adjust unique constraint comment to include info about the RecordNotUnique exception 2011-03-13 11:49:56 +01:00
Xavier Noria
b481574a33 copy-edits 8d96b89 2011-02-21 11:37:08 +01:00
Peer Allan
8d96b89110 Clarification of ActiveRecord ActiveModel validation documentation 2011-02-18 20:51:56 -06:00
Aaron Patterson
5b42e96602 make sure de-serialization happens on object instantiation 2011-02-01 15:23:55 -08:00
Aaron Patterson
a0fac71922 store the serialized column values in the @attributes hash 2011-02-01 14:25:47 -08:00
Aaron Patterson
a6cf6ec98b move the coders to the serialized_attributes hash 2011-02-01 14:25:46 -08:00
Ryan Bigg
f612069ae1 Fix documentation for validates_uniqueness_of to NOT have a :scope argument as the prime example. Show scope examples after prime example. 2011-01-06 20:10:01 +10:00
Emilio Tagua
e2bad8a2e7 No need to create a variables to use them once. 2010-11-24 01:37:02 +08:00
David Chelimsky
1f06652a57 use persisted? instead of new_record? wherever possible
- persisted? is the API defined in ActiveModel
- makes it easier for extension libraries to conform to ActiveModel APIs
  without concern for whether the extended object is specifically
  ActiveRecord

[#5927 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-09 13:54:04 -02:00
Michael Koziarski
3d6eea0221 Update the validates_uniqueness_of documentation to tell you to use a unique index.
The other options mentioned were not good ideas and disclaimed as such in the documentation.
2010-11-08 10:16:40 +13:00
Aaron Patterson
c6015cbcd8 serialized attributes should be serialized before validation [#5525 state:resolved] 2010-09-07 13:39:27 -07: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
Neeraj Singh
1ce40ca562 ensuring that description does not exceed 100 columns 2010-08-02 12:25:26 -04: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
Jeremy Kemper
86dda361e2 Avoid deprecated String#to_a by using Array.wrap(...) instead of Array(...) 2010-04-10 22:37:36 -07:00
Aaron Patterson
98d2d8ce2c use the database to lower case strings rather than ruby. [#4293 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
2010-03-28 22:16:34 -07:00
Pratik Naik
cd90dcb1bd Rename Model.active_relation to Model.unscoped 2010-01-17 03:00:56 +05:30
José Valim
93898b389b Ensure new validates works with uniqueness validator. 2010-01-08 23:50:31 +01:00
Pratik Naik
4a7a14b0e1 Use relations to build uniqueness conditions 2010-01-02 03:46:08 +05:30
Jeremy Kemper
1b91f534ce Fix uniqueness validation: with_exclusive_scope is not public 2009-12-28 14:06:22 -08:00
José Valim
74098e4cb6 No need to use ValidationsRepairHelper hack on ActiveModel anymore, Model.reset_callbacks(:validate) is enough. However, tests in ActiveRecord are still coupled, so moved ValidationsRepairHelper back there. 2009-12-23 13:30:58 +01:00
José Valim
44cd9e0e71 ActiveRecord::Validations are now built on top of Validator as well. 2009-12-23 12:14:00 +01:00
Elise Huard
c5896bfd84 validate uniqueness with limit in utf8
[#2653 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-08-09 12:50:04 -07:00
Pratik Naik
22ad30ed60 Move validate_on_create and validate_on_update from ActiveModel to ActiveRecord 2009-03-21 01:11:38 +00:00
Pratik Naik
638333b7a1 Move uniqueness and association validations to Active Record 2009-03-19 23:44:30 +00:00