diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-20 15:30:41 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-20 15:30:41 -0700 |
commit | 3b93ca221d3a1b777bd880c18f52010cbd56c18c (patch) | |
tree | 7b49713994125de123775102eac2655d7b29b231 /activerecord/lib | |
parent | daab53d8c0bca1114c1485d0dcc52858a264ab9e (diff) | |
parent | 46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd (diff) | |
download | rails-3b93ca221d3a1b777bd880c18f52010cbd56c18c.tar.gz rails-3b93ca221d3a1b777bd880c18f52010cbd56c18c.tar.bz2 rails-3b93ca221d3a1b777bd880c18f52010cbd56c18c.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 6 | ||||
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 27 |
2 files changed, 9 insertions, 24 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 573c6a4f02..1d63bb2f84 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -364,8 +364,10 @@ module ActiveRecord end def current_version - Base.connection.select_values( - "SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).max || 0 + version = Base.connection.select_values( + "SELECT version FROM #{schema_migrations_table_name}" + ).map(&:to_i).max rescue nil + version || 0 end def proper_table_name(name) diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 86cda9aa66..1d12ea8ad7 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -281,24 +281,7 @@ module ActiveRecord end base.send :include, ActiveSupport::Callbacks - - VALIDATIONS.each do |validation_method| - base.class_eval <<-"end_eval" - def self.#{validation_method}(*methods, &block) - methods = CallbackChain.build(:#{validation_method}, *methods, &block) - self.#{validation_method}_callback_chain.replace(#{validation_method}_callback_chain | methods) - end - - def self.#{validation_method}_callback_chain - if chain = read_inheritable_attribute(:#{validation_method}) - return chain - else - write_inheritable_attribute(:#{validation_method}, CallbackChain.new) - return #{validation_method}_callback_chain - end - end - end_eval - end + base.define_callbacks *VALIDATIONS end # All of the following validations are defined in the class scope of the model that you're interested in validating. @@ -404,7 +387,7 @@ module ActiveRecord # method, proc or string should return or evaluate to a true or false value. # * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should # not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The - # method, proc or string should return or evaluate to a true or false value. + # method, proc or string should return or evaluate to a true or false value. def validates_confirmation_of(*attr_names) configuration = { :message => ActiveRecord::Errors.default_error_messages[:confirmation], :on => :save } configuration.update(attr_names.extract_options!) @@ -438,7 +421,7 @@ module ActiveRecord # method, proc or string should return or evaluate to a true or false value. # * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should # not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The - # method, proc or string should return or evaluate to a true or false value. + # method, proc or string should return or evaluate to a true or false value. def validates_acceptance_of(*attr_names) configuration = { :message => ActiveRecord::Errors.default_error_messages[:accepted], :on => :save, :allow_nil => true, :accept => "1" } configuration.update(attr_names.extract_options!) @@ -520,7 +503,7 @@ module ActiveRecord # method, proc or string should return or evaluate to a true or false value. # * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should # not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The - # method, proc or string should return or evaluate to a true or false value. + # method, proc or string should return or evaluate to a true or false value. def validates_length_of(*attrs) # Merge given options with defaults. options = { @@ -597,7 +580,7 @@ module ActiveRecord # attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. # # Because this check is performed outside the database there is still a chance that duplicate values - # will be inserted in two parallel transactions. To guarantee against this you should create a + # will be inserted in two parallel transactions. To guarantee against this you should create a # unique index on the field. See +add_index+ for more information. # # Configuration options: |