ActiveRecord::StatementInvalid (Mysql2::Error: Table Doesn't Exist. RoR sorcery

1.2k Views Asked by At

Rails 4.2.10 Ruby 2.5.0

I cannot get to the register page for sorcery because i get the error:

ActiveRecord::StatementInvalid (Mysql2::Error: Table 'geofly_test.users' doesn't exist: SHOW FULL FIELDS FROM users): app/controllers/users_controller.rb:29:in `new'

development log:

Processing by WelcomeController#index as HTML Rendered shared/_login.html.erb (10.4ms) Rendered welcome/index.html.erb within layouts/application (33.2ms) Completed 200 OK in 84ms (Views: 72.7ms | ActiveRecord: 0.0ms)

Started GET "/assets/images/ajax-loader.gif" for 64.134.216.142 at 2018-03-24 22:13:50 +0000 Cannot render console from 192.168.5.71! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

Started HEAD "/users/new" for 104.51.164.9 at 2018-03-24 22:16:42 +0000 Cannot render console from 104.51.164.9! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255 Processing by UsersController#new as HTML Completed 500 Internal Server Error in 105ms (ActiveRecord: 4.7ms)

ActiveRecord::StatementInvalid (Mysql2::Error: Table 'geofly_test.users' doesn't exist: SHOW FULL FIELDS FROM users): app/controllers/users_controller.rb:29:in `new'


I set config.web_console.whitelisted_ips = '104.51.164.9', '64.134.216.142', '192.168.5.71' in development.rb

mysql shows that the users table and geofly_test db exists:

mysql> use geofly_test

Database changed
mysql> show tables;
+-----------------------+
| Tables_in_geofly_test |
+-----------------------+
| delayed_jobs          |
| schema_migrations     |
| users                 |
+-----------------------+

3 rows in set (0.00 sec)

database.yml

`cat schema.rb # encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150401095514) do

  create_table "delayed_jobs", force: :cascade do |t|
    t.integer  "priority",   limit: 4,     default: 0, null: false
    t.integer  "attempts",   limit: 4,     default: 0, null: false
    t.text     "handler",    limit: 65535,             null: false
    t.text     "last_error", limit: 65535
    t.datetime "run_at"
    t.datetime "locked_at"
    t.datetime "failed_at"
    t.string   "locked_by",  limit: 255
    t.string   "queue",      limit: 255
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree

  create_table "users", force: :cascade do |t|
    t.string   "email",                           limit: 255,             null: false
    t.string   "crypted_password",                limit: 255
    t.string   "salt",                            limit: 255
    t.string   "name",                            limit: 255
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "remember_me_token",               limit: 255
    t.datetime "remember_me_token_expires_at"
    t.integer  "failed_logins_count",             limit: 4,   default: 0
    t.datetime "lock_expires_at"
    t.string   "unlock_token",                    limit: 255
    t.datetime "last_login_at"
    t.datetime "last_logout_at"
    t.datetime "last_activity_at"
    t.string   "last_login_from_ip_address",      limit: 255
    t.string   "activation_state",                limit: 255
    t.string   "activation_token",                limit: 255
    t.datetime "activation_token_expires_at"
    t.string   "reset_password_token",            limit: 255
    t.datetime "reset_password_token_expires_at"
    t.datetime "reset_password_email_sent_at"
  end

  add_index "users", ["activation_token"], name: "index_users_on_activation_token", using: :btree
  add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
  add_index "users", ["last_logout_at", "last_activity_at"], name: "index_users_on_last_logout_at_and_last_activity_at", using: :btree
  add_index "users", ["remember_me_token"], name: "index_users_on_remember_me_token", using: :btree
  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", using: :btree
  add_index "users", ["unlock_token"], name: "index_users_on_unlock_token", using: :btree

end
`  cat config/database.yml
# MySQL.Versions 4.1 and 5.0 are recommended.
# 
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
database: geofly_development
  pool: 5
  username: root
  password: ****
  host: localhost
  socket: /var/run/mysqld/mysqld.sock



test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: geofly_test
  pool: 5
  username: root
  password: ***
  socket: /var/run/mysqld/mysqld.sock


production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: geofly_production
  pool: 5
  username: root
  password: ***
  host: localhost
  socket: /var/run/mysqld/mysqld.sock

cat schema.rb
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150401095514) do

  create_table "delayed_jobs", force: :cascade do |t|
    t.integer  "priority",   limit: 4,     default: 0, null: false
    t.integer  "attempts",   limit: 4,     default: 0, null: false
    t.text     "handler",    limit: 65535,             null: false
    t.text     "last_error", limit: 65535
    t.datetime "run_at"
    t.datetime "locked_at"
    t.datetime "failed_at"
    t.string   "locked_by",  limit: 255
    t.string   "queue",      limit: 255
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree

  create_table "users", force: :cascade do |t|
    t.string   "email",                           limit: 255,             null: false
    t.string   "crypted_password",                limit: 255
    t.string   "salt",                            limit: 255
    t.string   "name",                            limit: 255
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "remember_me_token",               limit: 255
    t.datetime "remember_me_token_expires_at"
    t.integer  "failed_logins_count",             limit: 4,   default: 0
    t.datetime "lock_expires_at"
    t.string   "unlock_token",                    limit: 255
    t.datetime "last_login_at"
    t.datetime "last_logout_at"
    t.datetime "last_activity_at"
    t.string   "last_login_from_ip_address",      limit: 255
    t.string   "activation_state",                limit: 255
    t.string   "activation_token",                limit: 255
    t.datetime "activation_token_expires_at"
    t.string   "reset_password_token",            limit: 255
    t.datetime "reset_password_token_expires_at"
    t.datetime "reset_password_email_sent_at"
  end

  add_index "users", ["activation_token"], name: "index_users_on_activation_token", using: :btree
  add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
  add_index "users", ["last_logout_at", "last_activity_at"], name: "index_users_on_last_logout_at_and_last_activity_at", using: :btree
  add_index "users", ["remember_me_token"], name: "index_users_on_remember_me_token", using: :btree
  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", using: :btree
  add_index "users", ["unlock_token"], name: "index_users_on_unlock_token", using: :btree

end
0

There are 0 best solutions below