开发者

How to avoid updating update_at flag while updating associated model in active record?

开发者 https://www.devze.com 2022-12-21 01:14 出处:网络
My association to models as follows People model belongs_to :category has_one :account, :through => :category

My association to models as follows

People model

belongs_to :category

has_one :account, :through => :category

category model

belongs_to :account

has_many :bookings

acc开发者_开发技巧ount model

has_many :categories

Level model

accepts_nested_attributes :peoples

I wrote

@level.update_attributes(params[:level])

in Level controller.

Here when I update the level model then it also updates the updated_at flag in account_model. I want to avoid the update happen in account model i.e, avoid setting up updated_at flag in account model. how can I avoid this?


I used to do something like this:

Account.record_timestamps = false
level.save
Account.record_timestamps = true

You can make it look prettier by creating a wrapper method which will receive a block to execute without timestamps.

0

精彩评论

暂无评论...
验证码 换一张
取 消