Reputation: 187
I have an rails 5 app which works perfectly in my local machine with PostgreSQL locally installed.
I pushed my app to heroku and the login page of the app appears correctly. But when I try to login to the app I get an error. Checking the logs give following output.
2016-10-26T04:21:48.515201+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=teamwallet.herokuapp.com request_id=94268ad1-1f86-4caf-80ae-61799fdddc5b fwd="182.57.131.204" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-10-26T04:21:54.410775+00:00 heroku[router]: at=info method=POST path="/" host=teamwallet.herokuapp.com request_id=52da63d5-afbd-4e8d-9d8a-51b04d077a21 fwd="182.57.131.204" dyno=web.1 connect=0ms service=7ms status=500 bytes=1669
2016-10-26T04:21:54.435325+00:00 app[web.1]: I, [2016-10-26T04:21:54.435257 #3] INFO -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] Started POST "/" for 182.57.131.204 at 2016-10-26 04:21:54 +0000
2016-10-26T04:21:54.435994+00:00 app[web.1]: I, [2016-10-26T04:21:54.435933 #3] INFO -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] Processing by SessionsController#login_attempt as HTML
2016-10-26T04:21:54.436093+00:00 app[web.1]: I, [2016-10-26T04:21:54.436045 #3] INFO -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] Parameters: {"utf8"=>"✓", "authenticity_token"=>"xEvOCcjU8FZyt2OlypuNIifhucXsveX6TOGIXwkpddO7Dt9cEQyJrS/5Kw+trW35eo/jtv+A2IkuIzYHJUt4tQ==", "username_or_email"=>"admin", "login_password"=>"[FILTERED]", "commit"=>"Log In"}
2016-10-26T04:21:54.438633+00:00 app[web.1]: I, [2016-10-26T04:21:54.438587 #3] INFO -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] Completed 500 Internal Server Error in 2ms (ActiveRecord: 1.7ms)
2016-10-26T04:21:54.439261+00:00 app[web.1]: F, [2016-10-26T04:21:54.439180 #3] FATAL -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21]
2016-10-26T04:21:54.439305+00:00 app[web.1]: F, [2016-10-26T04:21:54.439242 #3] FATAL -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
2016-10-26T04:21:54.439306+00:00 app[web.1]: LINE 8: WHERE a.attrelid = '"users"'::regclass
2016-10-26T04:21:54.439307+00:00 app[web.1]: ^
2016-10-26T04:21:54.439308+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2016-10-26T04:21:54.439309+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
2016-10-26T04:21:54.439310+00:00 app[web.1]: (SELECT c.collname FROM pg_collation c, pg_type t
2016-10-26T04:21:54.439311+00:00 app[web.1]: WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),
2016-10-26T04:21:54.439311+00:00 app[web.1]: col_description(a.attrelid, a.attnum) AS comment
2016-10-26T04:21:54.439312+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2016-10-26T04:21:54.439313+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2016-10-26T04:21:54.439313+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2016-10-26T04:21:54.439314+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2016-10-26T04:21:54.439315+00:00 app[web.1]: ORDER BY a.attnum
2016-10-26T04:21:54.439316+00:00 app[web.1]: ):
2016-10-26T04:21:54.439363+00:00 app[web.1]: F, [2016-10-26T04:21:54.439302 #3] FATAL -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21]
2016-10-26T04:21:54.439411+00:00 app[web.1]: F, [2016-10-26T04:21:54.439359 #3] FATAL -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] app/models/user.rb:23:in `authenticate'
2016-10-26T04:21:54.439458+00:00 app[web.1]: F, [2016-10-26T04:21:54.439406 #3] FATAL -- : [52da63d5-afbd-4e8d-9d8a-51b04d077a21] app/controllers/sessions_controller.rb:11:in `login_attempt'
Upvotes: 0
Views: 78
Reputation: 26788
Your error says this:
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
it's really easy to forget, but Heroku doesn't automatically run migrations.
From the heroku docs https://devcenter.heroku.com/articles/rake
# shell
heroku run rake db:migrate
heroku restart
Upvotes: 1
Reputation: 23711
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
You forgot to run the migrations on heroku. Run this command on your console
heroku run rake db:migrate
Upvotes: 1