Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #14390 from huoxito/true-touch

Still touch associations when theres no timestamp
  • Loading branch information...
commit 05f62fcbc2629f3a5de9f8ab6468bc56ddbc31a3 1 parent 7f9cb9c
@rafaelfranca rafaelfranca authored
View
2  activerecord/lib/active_record/persistence.rb
@@ -448,6 +448,8 @@ def touch(name = nil)
@changed_attributes.except!(*changes.keys)
primary_key = self.class.primary_key
self.class.unscoped.where(primary_key => self[primary_key]).update_all(changes) == 1
+ else
+ true
end
end
View
11 activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -340,6 +340,17 @@ def test_belongs_to_with_touch_option_on_touch
assert_queries(1) { line_item.touch }
end
+ def test_belongs_to_with_touch_option_on_touch_without_updated_at_attributes
+ assert !LineItem.column_names.include?("updated_at")
+
+ line_item = LineItem.create!
+ invoice = Invoice.create!(line_items: [line_item])
+ initial = invoice.updated_at
+ line_item.touch
+
+ refute_equal initial, invoice.reload.updated_at
+ end
+
def test_belongs_to_with_touch_option_on_touch_and_removed_parent
line_item = LineItem.create!
Invoice.create!(line_items: [line_item])
Please sign in to comment.
Something went wrong with that request. Please try again.