MushroomObserver / mushroom-observer

A website for sharing observations of mushrooms.
https://mushroomobserver.org
MIT License
77 stars 25 forks source link

Simplify route definitions for Names, Locations, Descriptions, and Versions #2065

Closed nimmolo closed 5 months ago

nimmolo commented 5 months ago

The way I originally did these has been annoying me for awhile, it was super verbose.

Using Rails route helper defaults more consistently, and therefore getting a more legible and less verbose routes file, means allowing Rails to compose the route names, which must end with the name of the controller. I admit I don't like some of these route names much (particularly version_of_**name**_path instead of name_version_path), but that particular path helper, and most of these, are very seldom used, if ever.

What I like about this is it makes it easier to grasp the structure of the app from the routes file. You can tell what depends on what.

Doing this required changing a couple param names (for a description's parent name/location) from id to name_id/location_id for a couple routes. But "shallow" routing means you don't have to always pass a parent id for a nested resource — only for the new/create and index routes, where there is no id for the resource itself.

coveralls commented 5 months ago

Coverage Status

coverage: 94.394%. remained the same when pulling c065ea8b209393e7b95c7643e4c4caae6ee21a06 on nimmo-description-routes into a2a9bb1d5866bb5a5c6d2f18d596f824502f72d8 on main.