rails/rails — pull request #14390 by huoxito (2014-03-15 01:30:20+00:00)
Title: Still touch associations when theres no timestamp

Prior to Rails 4.0.4 when touching a object which doesn't have timestamp
attributes (updated_at / updated_on) rails would still touch all
associations. After 73ba2c14cd7d7dfb2d132b18c47ade995401736f it updates
associations but rollsback because `touch` would return nil since
there's no timestamp attribute.

This sounds a bit insane (touching an object without timestamps) but I came through it today while upgrading and just felt like reporting anyway due to being a change of behaviour between minor releases.

The following would pass on 4.0.3 but fails on 4.0.4

```ruby
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', path: '../rails'
gem 'sqlite3'
GEMFILE

system 'bundle'
end

require 'bundler'
Bundler.setup(:default)

require 'active_record'
require 'minitest/autorun'
require 'logger'

ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
create_table :products do |t|
t.timestamps
end

create_table :assets do |t|
t.integer :product_id
end
end

class Product < ActiveRecord::Base
has_many :assets
end

class Asset < ActiveRecord::Base
belongs_to :product, touch: true
end

class BugTest < MiniTest::Unit::TestCase
def test_association_stuff
product = Product.create!
image = Asset.create! product: product
initial = product.reload.updated_at
image.touch

refute_equal initial, product.reload.updated_at
end
end
```