例えは、Student has_many Evaluationsの時、Student.destroyをするとエラーする。
しか〜し。
class Student < 〜 has_many :evaluations, :dependent => :destroy end
とすると、関連するObjをdestroy時にdestroyしてくれる。
但し、デストロイはチェーンにできるので、よく考えて使わないと、思わぬデータが消える。
基本的に、子を消せばOK
例えは、Student has_many Evaluationsの時、Student.destroyをするとエラーする。
しか〜し。
class Student < 〜 has_many :evaluations, :dependent => :destroy end
とすると、関連するObjをdestroy時にdestroyしてくれる。
但し、デストロイはチェーンにできるので、よく考えて使わないと、思わぬデータが消える。
基本的に、子を消せばOK