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.
coverage: 94.394%. remained the same
when pulling c065ea8b209393e7b95c7643e4c4caae6ee21a06 on nimmo-description-routes
into a2a9bb1d5866bb5a5c6d2f18d596f824502f72d8 on main.
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 ofname_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
toname_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 thenew
/create
andindex
routes, where there is noid
for the resource itself.