Tobias Lütke
cdad2d41e1
Consolidated different create and create! versions to call through to the base class with scope. This fixes inconsistencies, especially related to protected attribtues.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5684 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-12-06 00:13:31 +00:00
Jeremy Kemper
9594832a8d
validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. Closes #5716 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5589 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-11-20 10:51:50 +00:00
Jeremy Kemper
88bd86e8bc
Run validations in the order they were declared. Closes #6657 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5588 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-11-20 10:12:38 +00:00
Jeremy Kemper
5b979ed8ff
Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. Closes #6495 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-11-05 19:20:39 +00:00
Jamis Buck
e411b545a5
a few more deprecation improvements
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5360 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-10-24 17:27:16 +00:00
David Heinemeier Hansson
9fd88d7939
Deprecated add_on_boundary_breaking (use validates_length_of instead) ( closes #6292 ) [BobSilva]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5255 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-10-09 01:42:09 +00:00
Jeremy Kemper
7c4b6a55b6
Rollback [4917]. Closes #785 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5067 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-09-07 21:34:35 +00:00
David Heinemeier Hansson
85fbb22f07
Backed out of new_record? to new? transformation as it would screw up existing models that did boolean calls on "new" attributes [DHH]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5018 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-09-05 18:54:24 +00:00
David Heinemeier Hansson
9d7e6432b2
Deprecated ActiveRecord::Base.new_record? in favor of ActiveRecord::Base.new? (old version still works until Rails 2.0) [DHH]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5017 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-09-05 18:48:10 +00:00
Jeremy Kemper
f3d6726dfa
Document validates_presences_of behavior with booleans: you probably want validates_inclusion_of :attr, :in => [true, false]. Closes #2253 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4980 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-09-04 06:33:22 +00:00
Jeremy Kemper
d9839c1952
validates_confirmation_of only kicks in when the attribute, rather than its confirmation, is present. Closes #785 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4917 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-09-03 17:53:51 +00:00
Jeremy Kemper
38d1a4aa09
alias_method_chain preserves method punctuation so foo, foo?, and foo! may be chained with the same feature.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4482 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-06-21 20:40:14 +00:00
Jeremy Kemper
c50113bc61
create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.)
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-19 01:05:20 +00:00
Marcel Molina
9f92dd3984
Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4312 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-29 20:20:22 +00:00
Marcel Molina
6186490962
Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4310 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-29 18:10:14 +00:00
Marcel Molina
3ba7c53b5a
Add warning about the proper way to validate the presence of a foreign key. Closes #4147 . [Francois Beausoleil <francois.beausoleil@gmail.com>]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4285 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-26 22:06:28 +00:00
Jamis Buck
010a10f3a1
Add ActiveRecord::Errors#to_xml
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4243 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-21 17:04:00 +00:00
Marcel Molina
37758cde13
DRY up and tweak style of the validation error object.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4213 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-15 23:22:57 +00:00
Rick Olson
bdb2a2f1cb
Add :case_sensitive option to validates_uniqueness_of ( closes #3090 ) [Rick]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4207 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-12 20:42:13 +00:00
David Heinemeier Hansson
109c56df3a
Doc fix #3960 [jonrailsdev@shumi.org]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4142 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-03 18:47:49 +00:00
David Heinemeier Hansson
fed7d334f2
Fixed documentation
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4078 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-28 03:06:40 +00:00
David Heinemeier Hansson
31199a9e4a
Update description
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4074 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-28 01:11:09 +00:00
David Heinemeier Hansson
4c7555aef7
Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's ( closes #1861 , #2477 ) [DHH]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3707 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-28 20:37:21 +00:00
David Heinemeier Hansson
c5ff33cd7b
Example for validates_presence_of method ( closes #3966 ) [Robby Russell]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3677 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-26 23:58:22 +00:00
David Heinemeier Hansson
272729e0a3
Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes ( closes #3699 ) [Masao Mutoh]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3654 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-25 23:54:57 +00:00
David Heinemeier Hansson
e9d4b367cc
Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) ( closes #3920 , #3320 ) [contact@lukeredpath.co.uk]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3639 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-23 05:09:04 +00:00
Tobias Lütke
796295dba6
ActiveRecord::RecordInvalid now states which validations failed in its default error message
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3544 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-05 17:39:54 +00:00
David Heinemeier Hansson
f791fe7621
Silly me
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3513 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-01 04:18:07 +00:00
David Heinemeier Hansson
1f8f982ee0
Added Errors#any? to mean !Errors#empty? [DHH]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3510 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-02-01 04:11:24 +00:00
Marcel Molina
f1a01c80db
Disambiguate table names for columns in validates_uniquness_of's WHERE clause. Closes #3423 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3402 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-01-13 01:51:45 +00:00
Marcel Molina
2e42167058
Allow validate_uniqueness_of to be scoped by more than just one column. Closes #1559 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3206 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-12-02 04:30:46 +00:00
Marcel Molina
119155bebb
Revert [3130]. Behavior of introducing Kernel.binding causes breakage.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3142 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-21 09:34:10 +00:00
Jeremy Kemper
5177333e70
Use Kernel.binding rather than binding to allow columns of that name. References #2973 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3139 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-21 08:34:50 +00:00
Jeremy Kemper
2076dca63f
r3095@asus: jeremy | 2005-11-15 22:40:51 -0800
...
Ticket #1874 - Firebird adapter
r3107@asus: jeremy | 2005-11-16 00:06:14 -0800
quote column aliases
r3108@asus: jeremy | 2005-11-16 00:08:12 -0800
quote columns in construct_conditions_from_arguments. update sequence_name docs. introduce prefetched primary keys.
r3109@asus: jeremy | 2005-11-16 00:09:08 -0800
double-quote rather than single-quote sqlite columns
r3110@asus: jeremy | 2005-11-16 00:09:56 -0800
quote column names and use attribute_condition in validates_uniqueness_of
r3111@asus: jeremy | 2005-11-16 00:12:24 -0800
Use QUOTED_TYPE constant in tests
r3112@asus: jeremy | 2005-11-16 00:13:28 -0800
restrict test_inserts_with_pre_and_suffix to those adapters which support migrations
r3113@asus: jeremy | 2005-11-16 00:14:09 -0800
Use QUOTED_TYPE constant in tests
r3114@asus: jeremy | 2005-11-16 00:14:30 -0800
Use QUOTED_TYPE constant in tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3051 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-16 08:16:54 +00:00
Jamis Buck
7321a41e1b
Make Validations#create! use the current scope
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2984 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-12 05:09:05 +00:00
Jeremy Kemper
ae6a513bd1
Include the Enumerable module in ActiveRecord::Errors.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2981 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-11 18:49:01 +00:00
Florian Weber
e6f412def3
Allow capital letters in the email address in the the validates_format_of example
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2950 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-09 10:38:48 +00:00
Jeremy Kemper
44d1420757
Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors).
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2863 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-03 18:54:16 +00:00
David Heinemeier Hansson
a8eea0b04b
Fix docs ( closes #2491 )
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2744 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-26 13:05:48 +00:00
Florian Weber
49bee8826a
Minor documentation fix
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2726 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-25 10:44:07 +00:00
Jeremy Kemper
e19bd169fa
Association validation does not belong in a before_save callback: move it into a validation method. Restores the expected model.valid? == model.save. Add tests for cancelling save by returning false from a before_save callback. Remove assumption that before_destroy's return value indicates whether the record was destroyed.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-02 02:00:50 +00:00
Jeremy Kemper
6d7551f1bb
r3604@asus: jeremy | 2005-09-26 19:10:42 -0700
...
Treat validates_size_of :within as a single validator rather than splitting it into to ends of the range, thus yield two error messages on nil (yuck)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2355 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-26 22:41:02 +00:00
Marcel Molina
1d738cab80
Make update_attribute use the same writer method that update_attributes uses.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2353 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-26 21:55:37 +00:00
David Heinemeier Hansson
c0e618cf6f
Refactored to a more readble form #1813
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2202 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-11 10:04:37 +00:00
Jamis Buck
73594d88f3
Fix typo in validations documentation #1938 [court3nay]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2010 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-08-14 08:50:51 +00:00
David Heinemeier Hansson
20d27f6b74
Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1603 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-07-02 07:52:29 +00:00
David Heinemeier Hansson
9ac02777e7
Clarified intentions of validates_associated #870
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1602 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-07-02 06:59:08 +00:00
David Heinemeier Hansson
3dfa56ccfb
Updated all references to the old find_first and find_all to use the new style #1511 [Marcel Molina]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1520 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-26 11:25:32 +00:00
David Heinemeier Hansson
3eed3272d7
Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1509 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-25 11:24:43 +00:00
Jamis Buck
e0537acaeb
Added ActiveRecord::Recursion to guard against recursive calls to #save
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-06-13 10:52:53 +00:00