Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ericlondon/rails4-has_many_through-accepts_nested_attributes_for-allow_destroy

Rails4 / has_many through / accepts_nested_attributes_for / allow_destroy / nested form
https://github.com/ericlondon/rails4-has_many_through-accepts_nested_attributes_for-allow_destroy

accepts-nested-attributes-for form has-many-through rails rails4 ruby

Last synced: about 1 month ago
JSON representation

Rails4 / has_many through / accepts_nested_attributes_for / allow_destroy / nested form

Awesome Lists containing this project

README

        

Rails4 / has_many through / accepts_nested_attributes_for / allow_destroy / nested form
=======================================================================================

Models:

```ruby
class Car < ActiveRecord::Base

has_many :garages
has_many :houses, through: :garages

accepts_nested_attributes_for :garages, allow_destroy: true

end
```

```ruby
class Garage < ActiveRecord::Base

belongs_to :car
belongs_to :house

accepts_nested_attributes_for :house

end
```

```ruby
class House < ActiveRecord::Base

has_many :garages
has_many :cars, through: :garages

end
```

Nested form here:

- http://localhost:3000/cars/1/edit
- https://github.com/EricLondon/Rails4-has_many_through-accepts_nested_attributes_for-allow_destroy/blob/master/rails4/app/views/cars/_form.html.erb