Posted about 3 years ago. Visible to the public.

Nested forms

Goals

  • Understand how nested attributes appear in the params.
  • See how the Rails form helpers encode the names of nested inputs.
  • Understand how the record and all of its nested attributes are saved in a transaction. That means the entire structure is saved or not.

Resources

Exercise: Showtimes for MovieDB

  • A movie has a list of showtimes. Each showtime consists of the name of the cinema, and the date (both can be simple text fields).
  • Expand the movie form with a simple interface that allows adding, editing and removing of showtimes. It is fine when you can only add 5 showtimes at a time.
  • Showtimes should validate the presence of cinema and date.
  • Also add a field total_showtimes that caches the number of total showtimes. Do not use Rails' counter cache mechanism.
  • When you delete a showtime, does total_showtimes decrease as expected?

Owner of this card:

Avatar
Henning Koch
Last edit:
over 2 years ago
by Natalie Krehan
Posted by Henning Koch to makandra Curriculum
This website uses cookies to improve usability and analyze traffic.
Accept or learn more