Reputation: 12563
I require to use update_column
in my Rails application to prevent callbacks from being run. I have my ActiveRecord model with enum:
class Car < ActiveRecord::Base
enum state: [:not_used, :used]
end
In normal scenario (i.e. when I do want the callbacks to run) I can use something like that:
@car.update_attribute :state, :not_used
Is it possible to do something similar with update_column
?
I am using Rails 4.2
Upvotes: 6
Views: 1548
Reputation: 390
update_column
doesn't recognize symbols as a variant of the enum. I think that you have to Use Car.states[:not_used]
instead of :not_used
. Like this:
@car.update_column :state, Car.states[:not_used]
Upvotes: 9