开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜