Rails4-has_many_through-accepts_nested_attributes_for-allow_destroy

Rails4 / has_many through / accepts_nested_attributes_for / allow_destroy / nested form

Stars
1
Committers
2

Rails4 / has_many through / accepts_nested_attributes_for / allow_destroy / nested form

Models:

class Car < ActiveRecord::Base

  has_many :garages
  has_many :houses, through: :garages

  accepts_nested_attributes_for :garages, allow_destroy: true

end
class Garage < ActiveRecord::Base

  belongs_to :car
  belongs_to :house

  accepts_nested_attributes_for :house

end
class House < ActiveRecord::Base

  has_many :garages
  has_many :cars, through: :garages

end

Nested form here: