April 2019
Beginner to intermediate
244 pages
6h 34m
English
Let’s take this one step further. In the last example, we were working with a single address via the embeds_one association. Let’s try adding support for multiple addresses (embeds_many).
The process is similar to having just a single address. The inputs_for function is smart enough to handle associations with one record or with many records; it will always generate as many sub-forms as needed. So if, for example, we had two addresses associated with the user record, inputs_for would create two sub-forms, one for each address.
There’s just one problem: we don’t have a way for users to add a new address.
Think about how things work with just one address. When users first fill out the form, the address ...
Read now
Unlock full access