You’re not receiving notifications from this thread.
Not able to override a column with default value
I have created this in migration,
created_by VARCHAR (64) DEFAULT CURRENT_USER, updated_by VARCHAR (64) DEFAULT CURRENT_USER
By default the current user values are stored but when i try to override like,
user = User.new user.created_by = "New User" user.updated_by = "New User" user.save
The above code is not saving the "New User" value into created_by and updated_by column and still its storing the adefault value on save.
I tried to override by adding the below in model
def created_by=(created_by_user) write_attribute(:created_by, created_by_user) end def updated_by=(updated_by_user) write_attribute(:updated_by, updated_by_user) end
also using super
def created_by=(created_by_user) super created_by_user end def updated_by=(updated_by_user) super updated_by_user end
Its not workig still and i also checkt at the db level there are no triggers.
Thanks in advance
This works fine with update_colum and not update_attributes or save! and from code there are no callbacks triggered for this model.