Search code examples
rubydatabaserakereset

Ruby 2.3.5 ActiveRecord::RecordNotFound cannot figure out how to delete


I thought I reset my databases but I appear to have residual users:

Couldn't find User with 'id'=4

app/controllers/application_controller.rb:7:in `current_user'

app/views/layouts/_top_nav.html.erb:29:in `_app_views_layouts__top_nav_html_erb__3420316131555447158_70352716890940'

app/views/layouts/application.html.erb:11:in `_app_views_layouts_application_html_erb___1486453009680454139_40255060'

def current_user
  @current_user ||= User.find(session[:user_id]) if session[:user_id]
end

helper_method :current_user

I've used bin/rake db:reset but I still get the following when I connect to the server:

D, [2018-03-03T03:12:09.426337 #11896] DEBUG -- : User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 4]]

How do I delete the users (I suspect users 1, 2, 3 will also need to be deleted)


Solution

  • The problem is the cookies are client side. What browser are you using? Try to clear your cookies on your browser.


    Perhaps you can use session.clear in your action :current_user by using debugger.