1
這是我的模型:mongoid after_remove回調不工作
class Country
include Mongoid::Timestamps
has_many :cities, after_add: :show_log, after_remove: :show_log
def show_log
puts "this is log!"
end
end
控制檯
這裏:
Country.first.cities.create FactoryGirl.attributes_for(:city)
=> [.....] this is log!
Country.first.cities.first.destroy
=> true
,你在第二個看,沒有什麼是登錄! mongoid after_remove出了什麼問題?