Hi everyone,
I’m encountering an issue with my Rails application and I could really use some guidance. I keep getting the following error:
ActiveRecord::RecordNotFound in UsersController#show
Couldn't find User with id=123
I’ve checked my database and the user with ID UR987 definitely exists, so I’m a bit puzzled as to why I’m getting this error. I’ve double-checked my controller and view files to make sure everything is set up correctly, but I haven’t been able to pinpoint the source of the problem.
def show
@user = User.find(params[:id])
end
And here’s the relevant part of my view file:
<%= @user.name %>
I’m using Rails 6.1 and Ruby 3.0. Could this be a version-specific issue, or am I missing something obvious in my code? I also check this : Handling ActiveRecord::RecordNotFound errors ruby on rails But I have not found any solution. Please guide me in this.
Thanks in advance!