My post previous post mentioned that I will add an item to a list.
In order to create a list
rails g model item description which generates:
Then you have to migrate your database and create your schema by running
rails db:migrate and then set up your associations in the models. A List has many items and an Item has many lists.
Then as always check your database within your console.
list = List.create(:description => "cookies")
milk = Item.create
milk.description = "Milk"
milk.list_id = list.id
milk.list_id = list
Great everything works. The has_many in items creates many methods and allows us to do something like this:
list.items.create(:description => "new shoes")
Feel free to checkout the final code on Github.
As always, thanks for reading!