Reputation: 26670
Does ActiveRecord model update itself after ActiveRecord::Base.connection.execute('UPDATE ...')
was fired or it needs to be reloaded?
Upvotes: 0
Views: 174
Reputation: 14412
No, every time you do something with the connection directly, you are on your own and need to make sure everything is in sync.
c = Car.create! name: "Car 1"
c.name # => "Car 1"
Car.connection.execute "UPDATE cars SET name = 'Car 2' WHERE id = 1"
c.name # => "Car 1"
c.reload.name # => "Car 2"
Upvotes: 1