brandoshmando
brandoshmando

Reputation: 5

ActionView::Template::Error (PG::Error: ERROR: column users.remember_token does not exist

I'm working through Hartl's tutorial, just finished up chapter 8 and attempted to push to Heroku. After doing so, I checked Heroku logs and found that I was getting an error:

2014-02-21T04:22:37.252893+00:00 app[web.1]: LINE 1: SELECT  "users".* FROM "users"  WHERE "users"."remember_toke...
2014-02-21T04:22:37.252893+00:00 app[web.1]:                                                  ^
2014-02-21T04:22:37.252893+00:00 app[web.1]: : SELECT  "users".* FROM "users"  WHERE "users"."remember_token" = 'da39a3ee5e6b4b0d3255bfef95601890afd80709' LIMIT 1
2014-02-21T04:22:37.252893+00:00 app[web.1]: LINE 1: SELECT  "users".* FROM "users"  WHERE "users"."remember_toke...
2014-02-21T04:22:37.252893+00:00 app[web.1]:                                               ^
2014-02-21T04:22:37.252893+00:00 app[web.1]: PG::Error: ERROR:  column users.remember_token does not exist
2014-02-21T04:22:37.252893+00:00 app[web.1]: PG::Error: ERROR:  column users.remember_token does not exist
2014-02-21T04:22:37.253670+00:00 app[web.1]:   Rendered layouts/_header.html.erb (3.7ms)
2014-02-21T04:22:37.253670+00:00 app[web.1]:   Rendered layouts/_header.html.erb (3.7ms)
2014-02-21T04:22:37.253827+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2014-02-21T04:22:37.253827+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2014-02-21T04:22:37.255866+00:00 app[web.1]:
2014-02-21T04:22:37.255866+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  column users.remember_token does not exist
2014-02-21T04:22:37.255866+00:00 app[web.1]:                                               ^

I've provided the schema.rb to show that I have run rake db:migrate: schema.rb:

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

  create_table "users", force: true do |t|
    t.string   "name"
    t.string   "email"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "password_digest"
    t.string   "remember_token"
  end

  add_index "users", ["email"], name: "index_users_on_email", unique: true
  add_index "users", ["remember_token"], name: "index_users_on_remember_token"

end

I'm using sqlite for this particular project. I've read a few things about heroku using Postgres and case sensitivity. Unfortunately, this doesn't help my issue because I created the column label in lowercase anyways.

I'm a heavy noob and this is the first Heroku error that I have encountered. I can't even tell where the logs are tracing the error back to. Any light that you can shed is much appreciated. Please let me know if there are any other files that I need to provide.

Upvotes: 0

Views: 540

Answers (2)

John Beynon
John Beynon

Reputation: 37507

You might have run the migration locally but have you run it on Heroku?

heroku run rake db:migrate

will do that for you

Upvotes: 1

franksort
franksort

Reputation: 3143

Things to check:

First, make sure the column exists in your local database (SQLite):

$ rails db
sqlite> .schema users

Next, make sure the column exists on Heroku (PostgreSQL):

$ heroku pg:psql
psql> \d+ users

Possible problem:

After you added the remember_token to your User model, you may have forgotten to commit your code to your Git repository before pushing to Heroku. Run:

$ git status

This will show you if you have any modified files that you haven't committed yet.

Upvotes: 0

Related Questions