【发布时间】:2015-03-13 19:17:25
【问题描述】:
就像after_add 回调has_and_belongs_to_many 关联一样,是否有任何回调或解决方法来获取belongs_to 关联的after_add 功能。
一种解决方法是在保存回调和脏对象功能之后/之前使用。
belongs_to :video
after_save :after_save_task
def after_save_task
do_stuff if video_id_changed?
end
def do_stuff
### do stuff
end
但我不能在 do_stuff 中 save(true),因为它进入了无限循环。
【问题讨论】:
标签: ruby-on-rails-4 associations belongs-to