susanBuck / e2-fall22

0 stars 0 forks source link

Question on products/missing #41

Closed andlearnmore closed 1 year ago

andlearnmore commented 1 year ago

I was able to make the error page work as indicated in the homework, but I have a question. If I understand correctly, we're simply returning this view if the user tries to visit a page for a product where the sku isn't found. It seemed, then, that there would be no need to define any methods or to define the 'products/missing' route in our routes.php file. Is that a 'best practice'--that if we don't want someone to actually type in e2.zipfoods.andlearn.me/products/missing, we should not define the route?

Thanks!

susanBuck commented 1 year ago

Hi @andlearnmore -

That is correct - there is no need to define a separate method or route to show a "product missing" view. You're instead just returning a "missing" view from the product show method/route.

Alternatively you could define a /products/missing method/route and redirect the user to that from the product show method/route when there is no product to show.

The main difference I see in these two approaches is just whether you want the user to continue to see the URL of the product that is missing, or if you for some reason you want to obscure that so that they only end up seeing /product/missing.

Both from a programmatic standpoint, neither approach has an advantage over the other - just two different ways of handling it.

Good question.

andlearnmore commented 1 year ago

Thank you @susanBuck! That explanation is really helpful.