diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-08 19:14:35 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-08 19:14:35 -0300 |
commit | 952014315926d370f2a0b681cb765948bf2e6883 (patch) | |
tree | 3abfe7e82554c09df4b2fe8a170e90cf1f0bcf02 /activerecord/lib/active_record | |
parent | ae9e1e9f6d08bbd5f5c1512b72d495168e9fa5e5 (diff) | |
parent | ed8a0a1c2370ab8715434ba824b2826d807401d5 (diff) | |
download | rails-952014315926d370f2a0b681cb765948bf2e6883.tar.gz rails-952014315926d370f2a0b681cb765948bf2e6883.tar.bz2 rails-952014315926d370f2a0b681cb765948bf2e6883.zip |
Merge commit 'rails/master'
Conflicts:
activerecord/test/cases/adapter_test.rb
activerecord/test/cases/method_scoping_test.rb
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 10 |
3 files changed, 18 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 0b7d6d9094..3da3d9d8cc 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -12,7 +12,7 @@ module ActiveRecord self.attribute_types_cached_by_default = ATTRIBUTE_TYPES_CACHED_BY_DEFAULT # Undefine id so it can be used as an attribute name - undef_method :id + undef_method(:id) if method_defined?(:id) end module ClassMethods diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 06bd2dab95..2eb2699949 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2494,6 +2494,11 @@ module ActiveRecord #:nodoc: @new_record || false end + # Returns true if this object has been destroyed, otherwise returns false. + def destroyed? + @destroyed || false + end + # :call-seq: # save(perform_validation = true) # @@ -2544,6 +2549,7 @@ module ActiveRecord #:nodoc: # options, use <tt>#destroy</tt>. def delete self.class.delete(id) unless new_record? + @destroyed = true freeze end @@ -2554,6 +2560,7 @@ module ActiveRecord #:nodoc: arel_table(true).where(arel_table[self.class.primary_key].eq(id)).delete end + @destroyed = true freeze end diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 7631f3ec35..d5d4808074 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -393,6 +393,16 @@ module ActiveRecord down(migrations_path, finish ? finish.version : 0) end + def forward(migrations_path, steps=1) + migrator = self.new(:up, migrations_path) + start_index = migrator.migrations.index(migrator.current_migration) + + return unless start_index + + finish = migrator.migrations[start_index + steps] + up(migrations_path, finish ? finish.version : 0) + end + def up(migrations_path, target_version = nil) self.new(:up, migrations_path, target_version).migrate end |