Working the hotrails.dev tutorial - Chapter 1 Basics
As noted in part 1 of this blog series, I am working thru the HotRails.dev tutorial and building a set of personal notes.
Note: Don’t read this; this is my learning notes. Go read HotRails.dev which is an ASTONISHINGLY GOOD, FANTASTIC, WONDERFUL tutorial. Seriously. Go there NOW and stop reading this.
Notes on Chapter 1 - A Simple CRUD Controller with Rails
In HotRails, he starts with a master model called a Quote; my version of this is a Meal.
Sidebar: I’m a pretty serious cook and I have a process for cooking a fancy meal – think Christmas / Thanksgiving / Easter / a big party meal. My process reduces cooking a meal to an information problem. Now if you’re a serious cook then the core limitation is always heat sources. I mean think about a Thanksgiving meal:
- Turkey uses the oven and cooks FOREVER and that ties up the oven for HOURS and HOURS
- If you want to make biscuits – which cook in the oven – they either need to be cooked before or cooked after
- And let’s say that you also want to make stuffing – but that isn’t in the bird (because stuffing in the bird makes the bird cook longer) – so that also needs to go in the oven – when do you cook that?
This is an explicit dependency structure – you can do it either way – but it requires a schedule – and that’s the desired output of this project, a schedule for when to cook what.
The way I make this all work is that for any large holiday meal, I plan it out on paper with something like this:
holiday_meal_planner.jpg
And then if you add in the fact that I’m juggling multiple recipes for any big meal, well, this only exacerbates the information problem.
So my goal for learning HotWire through HotRails is to parallel his structure (quote becomes meal) and build a reactive application for planning a holiday meal along the lines above.
Steps
bin/rails g system_test meals
touch test/fixtures/meals.yml
bin/rails test:system
rails generate model Meal name:string
bin/rails db:migrate
bin/rails generate controller Quotes
touch app/views/meals/index.html.erb
touch app/views/meals/_meal.html.erb
touch app/views/meals/new.html.erb
touch app/views/meals/edit.html.erb
touch app/views/meals/_form.html.erb
bundle install
bin/rails generate simple_form:install
touch app/views/meals/show.html.erb
bin/rails test:system