rockandrollwithemberjs / rarwe-issues

Errata and updates for the Rock and Roll with Ember.js book
https://rockandrollwithemberjs.com
43 stars 4 forks source link

Possible improper use of slug for path segment - Chapter 5 Nested routes #483

Closed GradedJestRisk closed 4 years ago

GradedJestRisk commented 4 years ago

I'm a newbie in web-app and found slug, in Wikipedia, refers to the last path fragment of URL.

In chapter 5 "Tuning", we've got

In our case, that would be /bands/:slug/songs.

The real slug would be songs

The following page seems to get in this way

One such URL would be /bands/pearl-jam/songs where the middle segment pearl-jam identifies the band.

But I finally understood

The middle segment of the path, the slug of the band

What you called slug is the band slug, the band "resource identifier" in the URL. It's the name, would it appear as a slug (but also as a path fragment). Eg. foo-fighters, as opposed to Foo Fighters, the band name in the UI.

So I suggest

In our case, that would be /bands/{band-slug}/songs.

balinterdi commented 4 years ago

I thought slug was used to describe a "semantic" identifier, one derived from a property of the resource. Checking the MDN docs, you're right, though.

I think the simplest would be to call it id from the start as a non-numeric id is also an id. That would make the route definition look like /bands/:id/songs.

That change needs to be carried through several chapters and the source code but I'll do it for the next release or the one after that. Thanks for pointing it out.

GradedJestRisk commented 4 years ago

Well, I'm happy to discover this glossary, thanks ! Maybe you don't need to fix all occurrences if that's time expensive, maybe just pointing out the word used in the book doesn't conform to MDN definition ? In opened this issue cause I'm newbie in web app, and it caused me some confusion. If most of the readers have basic web-app skills, they'll be fine with slug.