I have a model in rails with one_to_many relationship. When I delete the father, I'd like to delete all childrens. How should I do it? I want to delete all orders and its items when I delete a user
My models are:
class User < ActiveRecord::Base
has_many :orders, :foreign_key => "id_user"
end
class Order < ActiveRecord::Base
has_many :order_items, :foreign_key => "id_pedido"
belongs_to :user, :foreign_key => "id_usuer"
end
class OrderItem < ActiveRecord::Base
belongs_to :order, :foreign_key => "id_pedido"
end