Render notes#index from controller action
This commit refactors the notes#index template, extracting the
Note.all record retrieval logic into the controller.
The NotesController#index action invokes render with the
locals option to declare variables available as
template-local variables.
Most Rails template rendering documentation suggests that controllers pass references to templates by declaring and sharing instance variables.
This commit deviates from that convention by explicitly passing the
notes controller-local variable to the view template through as a
notes: key in the locals hash.
By being explicit about which variables our templates can access, our
templates’ data dependencies are more apparent and discoverable. Instead
of being unsure about which controller declares which instance variable,
we can inspect the render call that invoked the view and see an
exhaustive list of the variables that are available.
When we re-run the system tests, they’re still passing.