mdn / express-locallibrary-tutorial

Local Library website written in NodeJS/Express; example for the MDN server-side development NodeJS module: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs.
Creative Commons Zero v1.0 Universal
1.23k stars 695 forks source link

Confusion regarding the Part 6: Working with forms #154

Closed BatuhanBudak closed 1 year ago

BatuhanBudak commented 1 year ago

Before submitting the issue, check you have done the following:

What was incorrect, unhelpful, or unexpected?

I'm currently on Part 6: Working with forms of the tutorial and I've completed the sixth sub-article of this section. In the view section of this lesson, there is an instruction that states we should add the following code to book_form.pug template.

option( value=author._id selected=( author._id.toString()==book.author._id || author._id.toString()==book.author ) ? 'selected' : false ) #{author.name}

However, when I inspect the code from the repository I see the following line of code:

option(value=author._id selected=(author._id.toString()===book.author._id.toString() ? 'selected' : false) ) #{author.name}

Which is the old state of the code before the change to book_form view template in this lesson. I've checked both code blocks and both of them seem to work.

So this left me wondering if the below-mentioned statement regarding this change from the same lesson is redundant.

This code change is required so that the book_form can be used for both creating and updating book objects (without this, there is an error on the GET route when creating a form)

Which source should be followed?

.

What did you expect to see?

Settling differences between the tutorial and the code base.

Output logs

No response

Do you have anything more you want to share?

No response

github-actions[bot] commented 1 year ago

It looks like this is your first issue. Welcome! 👋 One of the project maintainers will be with you as soon as possible. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.

hamishwillee commented 1 year ago

Thanks - you're right. I can't find out why/how the worked project and the docs got out of sync, but the original view works fine and is much easier to understand. I have therefore removed the section from the "update" doc. Should be fixed when https://github.com/mdn/content/pull/23852 gets merged.