I am working on a Ruby on Rails app which which has the following path to view a user’s page
/pics/user/:id
:id being the generated id attribute. My question is that is the proper way for the the app to deal with a number that is not a user id in the place of :id.
The methods I was considering are; creating an Error page and redirect to it or redirecting to another page (in this case a page with the list of all the users) and generating an error message. Are either of these ideas correct, or should I do something else entirely?
My goal is to adhere to proper ruby on rails and web conventions as closely as possible.
Thanks!
Usually you will be doing
Model.find(params[:id])and that will raiseActiveRecord::RecordNotFoundthat is to make the web server send a404 Not Foundresponse.