prix-fixe

Expand History Expand History
Collapse History Collapse History

Use named route in notes#index

This commit refactors both our Request Routing and View layer’s code to share helper method.

The "/notes/new" String was duplicated in both the notes#index template and our application’s route declaration file.

A String value duplicated in this way across disparate files can be considered a “magic string”, since it’s equivalence in two seemingly unrelated areas of the codebase is both important and unclear.

By declaring the get "/notes/new" route declaration with the as: "new_notes" option, Rails will generate new_notes_path and new_notes_url routing helpers which are made available within the view layer.

Routing helpers are a discrete list of methods, so attempting to invoke a route helper that does not exist will raise a NoMethodError when invoked.

When we run the test suite, it passes.