One thing I'm proud of here is a got an association in the form here that can be
added or removed without any javascript. Totally progressively enhanced. It
works by using a submit button that makes a GET request. The submit name is
add_shift. If the controller sees that in the params, it builds a new shift on
the tracker so it shows up in the form. accepts_nested_attributes_for :shifts_trackers, allow_destroy: true takes care of deleting when a _destroy
param is passed. It's not the best looking erb, but it's still readable.
I also added a .multiple-nested class. If there's a form with a
.multiple-nested wrapper, any .field label inside will be hidden. This is so
you don't have the label repeating for every new nested association.
Screen Shot 2026年07月07日 at 16.00.35-fullpage
One thing I'm proud of here is a got an association in the form here that can be
added or removed without any javascript. Totally progressively enhanced. It
works by using a submit button that makes a GET request. The submit name is
`add_shift`. If the controller sees that in the params, it builds a new shift on
the tracker so it shows up in the form. `accepts_nested_attributes_for
:shifts_trackers, allow_destroy: true` takes care of deleting when a `_destroy`
param is passed. It's not the best looking erb, but it's still readable.
I also added a `.multiple-nested` class. If there's a `form` with a
`.multiple-nested` wrapper, any `.field label` inside will be hidden. This is so
you don't have the label repeating for every new nested association.
