ruby on rails - ActiveRecord::NoDatabaseError: local user with ID does not exist -


developing api-only rails app consume data api, filter out number of fields, , broadcast fields want public.

my app returning data normally, realized on source api level, changed data type 1 of fields of data we're exposing. accommodate, committed work, checked out new branch, ran migrations change data field's data type, decided wasn't happy how worked, rolled migration, committed, , checkout out master branch. app returning data normal. however, when test model's records in rails console using finder methods .first, .last, etc., error below. working fine before.

i've looked around , haven't seen threads on particular error (they seem deal finding individual records show page) - although this, , this thread (by extension) seem closest. , checking users on db i'm using shows user id ("501") in error not present.

what did , need can call finder methods again? need create user referenced in error in db? (and why not default user use connect db? did user id in error come from? matter?)

ps - in case it's relevant, used rake db:rollback rollback migration per this thread.

thanks in advance.

rails console

.2.1 :001 > koboapi.first activerecord::nodatabaseerror: local user id 501 not exist      /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis_adapter.rb:51:in `initialize'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis/create_connection.rb:37:in `new'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis/create_connection.rb:37:in `postgis_connection'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'     /users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'     /users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection' ... 13 levels...     /users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in `start'     /users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in `console'     /users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'     /users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `block in require'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require'     /users/toby/code/projects/koboapi-broker/bin/rails:9:in `<top (required)>'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `block in load'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'     /users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'     /users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'     /users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 

i'm getting records - they're coming database:

rails dbconsole

koboapi_development=# select * kobo_apis limit 1;   id  | lemurs_quantity | month_and_year | _geolocation | lemur_category | location_admin1 | location_admin2 | record_id | sighting_month | sighting_year ------+-----------------+----------------+--------------+----------------+-----------------+-----------------+-----------+----------------+---------------  1365 |               1 |                |              | i_dont_remembe | antsiranana     | diana           |   1234567 | no_response    | 2013 (1 row)  koboapi_development=# \du                              list of roles  role name |                   attributes                   | member of -----------+------------------------------------------------+-----------  [user]    | superuser, create role, create db, replication | {} 

from schema

activerecord::schema.define(version: 20160705203507)    # these extensions must enabled in order support database   enable_extension "plpgsql"   enable_extension "postgis"    create_table "kobo_apis", force: :cascade |t|     t.integer "lemurs_quantity"     t.date    "month_and_year"     t.text    "_geolocation"     t.text    "lemur_category"     t.string  "location_admin1"     t.string  "location_admin2"     t.integer "record_id"     t.string  "sighting_month"     t.string  "sighting_year"   end    create_table "my_spatial_table", force: :cascade |t|     t.geography "polygon_data", limit: {:srid=>4326, :type=>"polygon", :geographic=>true}   end  end 

my database.yml

development:   adapter: postgis   encoding: unicode   postgis_extension: postgis      # default postgis   postgis_schema: public          # default public   schema_search_path: public,postgis   database: koboapi_development   pool: 5  test:   adapter: postgresql   encoding: unicode   database: koboapi_test   pool: 5  production:   adapter: postgresql   encoding: unicode   database: koboapi_production   pool: 5 

it seems spring's problem, not database if you're getting error:

/users/yad/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect': local user id 501 not exist  (activerecord::nodatabaseerror) 

in rails root directory enter:

spring stop

it should say:

spring stopped.

and migration work after that!


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -