Need help in understanding Heroku logs - ruby-on-rails

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'

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

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

Related

Rails to heroku deploy issue

I try to deploy my rails app to heroku. I get issue in logs.
2019-09-05T21:30:24.764421+00:00 app[web.1]: D, [2019-09-05T21:30:24.764290 #10] DEBUG -- : [3adcd749-6637-4790-8b0d-dab833c46c47] [1m[36mUser Create (16.1ms)[0m [1m[32mINSERT INTO "users" ("name", "email", "note", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"[0m [["name", ""], ["email", ""], ["note", ""], ["created_at", "2019-09-05 21:30:24.745537"], ["updated_at", "2019-09-05 21:30:24.745537"]]
2019-09-05T21:30:24.766999+00:00 app[web.1]: D, [2019-09-05T21:30:24.766917 #10] DEBUG -- : [3adcd749-6637-4790-8b0d-dab833c46c47] [1m[35m (2.0ms)[0m [1m[35mCOMMIT[0m
2019-09-05T21:30:24.771504+00:00 app[web.1]: I, [2019-09-05T21:30:24.771419 #10] INFO -- : [3adcd749-6637-4790-8b0d-dab833c46c47] Completed 500 Internal Server Error in 161ms (ActiveRecord: 47.8ms)
2019-09-05T21:30:24.772177+00:00 app[web.1]: F, [2019-09-05T21:30:24.772096 #10] FATAL -- : [3adcd749-6637-4790-8b0d-dab833c46c47]
2019-09-05T21:30:24.772242+00:00 app[web.1]: F, [2019-09-05T21:30:24.772179 #10] FATAL -- : [3adcd749-6637-4790-8b0d-dab833c46c47] Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)):
2019-09-05T21:30:24.772293+00:00 app[web.1]: F, [2019-09-05T21:30:24.772241 #10] FATAL -- : [3adcd749-6637-4790-8b0d-dab833c46c47]
2019-09-05T21:30:24.772375+00:00 app[web.1]: F, [2019-09-05T21:30:24.772316 #10] FATAL -- : [3adcd749-6637-4790-8b0d-dab833c46c47] app/controllers/users_controller.rb:25:in block in create'
2019-09-05T21:30:24.772377+00:00 app[web.1]: [3adcd749-6637-4790-8b0d-dab833c46c47] app/controllers/users_controller.rb:23:increate'
2019-09-05T21:30:24.727793+00:00 heroku[router]: at=info method=POST path="/users" host=mailme-reminder.herokuapp.com request_id=3adcd749-6637-4790-8b0d-dab833c46c47 fwd="189.159.252.164" dyno=web.1 connect=1ms service=178ms status=500 bytes=1827 protocol=https
2019-09-05T21:30:24.913280+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mailme-reminder.herokuapp.com request_id=df1321b0-44d2-46ef-9015-45a7f2fc8c38 fwd="189.159.252.164" dyno=web.1 connect=1ms service=4ms status=304 bytes=48 protocol=https
2019-09-05T21:31:09.129802+00:00 app[web.1]: I, [2019-09-05T21:31:09.129668 #10] INFO -- : [17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643] Started GET "/" for 189.159.252.164 at 2019-09-05 21:31:09 +0000
2019-09-05T21:31:09.131458+00:00 app[web.1]: I, [2019-09-05T21:31:09.131337 #10] INFO -- : [17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643] Processing by UsersController#new as HTML
2019-09-05T21:31:09.138108+00:00 app[web.1]: I, [2019-09-05T21:31:09.138004 #10] INFO -- : [17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643] Rendering users/new.html.erb within layouts/application
2019-09-05T21:31:09.142089+00:00 app[web.1]: I, [2019-09-05T21:31:09.142006 #10] INFO -- : [17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643] Rendered users/new.html.erb within layouts/application (3.8ms)
2019-09-05T21:31:09.144723+00:00 app[web.1]: I, [2019-09-05T21:31:09.144626 #10] INFO -- : [17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643] Completed 200 OK in 13ms (Views: 9.4ms | ActiveRecord: 0.0ms)
2019-09-05T21:31:09.101818+00:00 heroku[router]: at=info method=GET path="/" host=mailme-reminder.herokuapp.com request_id=17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643 fwd="189.159.252.164" dyno=web.1 connect=1ms service=19ms status=200 bytes=5496 protocol=https
2019-09-05T21:31:26.058494+00:00 heroku[router]: at=info method=POST path="/users" host=mailme-reminder.herokuapp.com request_id=63bbddba-107e-47b5-a0ee-ca8da83a6b0e fwd="189.159.252.164" dyno=web.1 connect=1ms service=26ms status=500 bytes=1827 protocol=https
2019-09-05T21:31:26.085304+00:00 app[web.1]: I, [2019-09-05T21:31:26.085200 #14] INFO -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] Started POST "/users" for 189.159.252.164 at 2019-09-05 21:31:26 +0000
2019-09-05T21:31:26.086465+00:00 app[web.1]: I, [2019-09-05T21:31:26.086388 #14] INFO -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] Processing by UsersController#create as HTML
2019-09-05T21:31:26.086570+00:00 app[web.1]: I, [2019-09-05T21:31:26.086505 #14] INFO -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] Parameters: {"utf8"=>"✓", "authenticity_token"=>"DNicK64JMa2ApcaSeYrP84zdeZe7hDYc2HZktB0ObXp4IVmCobV4KJQnZ9UazBiROfn6sE/jsCredCh6HzMgwg==", "user"=>{"name"=>"Michael", "email"=>"example_email#example.com", "date_and_time"=>"2019/09/05 17:00", "note"=>"Check"}, "commit"=>"Remind Me"}
2019-09-05T21:31:26.092268+00:00 app[web.1]: D, [2019-09-05T21:31:26.092172 #14] DEBUG -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] [1m[35m (1.0ms)[0m [1m[35mBEGIN[0m
2019-09-05T21:31:26.096930+00:00 app[web.1]: D, [2019-09-05T21:31:26.096826 #14] DEBUG -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] [1m[36mUser Create (1.8ms)[0m [1m[32mINSERT INTO "users" ("name", "email", "note", "date_and_time", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id"[0m [["name", "Michael"], ["email", "example_email#example.com"], ["note", "Check"], ["date_and_time", "2019-09-05 22:00:00"], ["created_at", "2019-09-05 21:31:26.092480"], ["updated_at", "2019-09-05 21:31:26.092480"]]
2019-09-05T21:31:26.099330+00:00 app[web.1]: D, [2019-09-05T21:31:26.099250 #14] DEBUG -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] [1m[35m (2.0ms)[0m [1m[35mCOMMIT[0m
2019-09-05T21:31:26.102570+00:00 app[web.1]: I, [2019-09-05T21:31:26.102493 #14] INFO -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] Completed 500 Internal Server Error in 16ms (ActiveRecord: 4.8ms)
2019-09-05T21:31:26.103205+00:00 app[web.1]: F, [2019-09-05T21:31:26.103127 #14] FATAL -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e]
2019-09-05T21:31:26.103267+00:00 app[web.1]: F, [2019-09-05T21:31:26.103206 #14] FATAL -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)):
2019-09-05T21:31:26.103318+00:00 app[web.1]: F, [2019-09-05T21:31:26.103263 #14] FATAL -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e]
2019-09-05T21:31:26.103376+00:00 app[web.1]: F, [2019-09-05T21:31:26.103323 #14] FATAL -- : [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] app/controllers/users_controller.rb:25:in block in create'
2019-09-05T21:31:26.103377+00:00 app[web.1]: [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] app/controllers/users_controller.rb:23:increate'
Heroku doesn't support your case, you must use s3 as they mentioned in their doc https://devcenter.heroku.com/articles/active-storage-on-heroku here, else you will end up missing image after the instance restarted or after you deploy new version.
The files will go away when the app is deployed, or when it is automatically restarted (once every 24 hours)
There's no other better option, you can either:
Keep using heroku for the server and s3 for file storage (No charge for free tier, just keep a reminder to shut it down sometimes later)
Move all to AWS, so you don't have to use 2 providers.
If you are not actually using Active Storage, look in Config > Environments > production.rb and you should find the following lines;
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
Just comment out config.active_storage.service = :local to make it look like this:
# Store uploaded files on the local file system (see config/storage.yml for options)
# config.active_storage.service = :local
Or, remove both lines entirely.
Then, it should work fine on Heroku.

Connecting Postgresql to Rails in Heroku

So I recently deployed my Rails backend server to Heroku.
After a little struggling with passing from SQLite to PostgreSQL, I finally got everything running.
Now the problem is, I did rake db:create and rake db:migrate and that went without any errors but now when I make a REST call to the server I have this error (complete) :
2019-07-31T19:42:16.534355+00:00 app[web.1]: I, [2019-07-31T19:42:16.534259 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Started POST "/sessions" for 91.176.204.35 at 2019-07-31 19:42:16 +0000
2019-07-31T19:42:16.535824+00:00 app[web.1]: I, [2019-07-31T19:42:16.535063 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Processing by SessionsController#create as */*
2019-07-31T19:42:16.535947+00:00 app[web.1]: I, [2019-07-31T19:42:16.535882 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Parameters: {"email"=>"titivermeesch#gmail.com", "password"=>"[FILTERED]"}
2019-07-31T19:42:16.566455+00:00 app[web.1]: I, [2019-07-31T19:42:16.566340 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Completed 500 Internal Server Error in 30ms (ActiveRecord: 11.2ms)
2019-07-31T19:42:16.567845+00:00 app[web.1]: F, [2019-07-31T19:42:16.567772 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5]
2019-07-31T19:42:16.567954+00:00 app[web.1]: F, [2019-07-31T19:42:16.567879 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
2019-07-31T19:42:16.567957+00:00 app[web.1]: LINE 8: WHERE a.attrelid = '"users"'::regclass
2019-07-31T19:42:16.567959+00:00 app[web.1]: ^
2019-07-31T19:42:16.567961+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2019-07-31T19:42:16.567962+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
2019-07-31T19:42:16.567964+00:00 app[web.1]: c.collname, col_description(a.attrelid, a.attnum) AS comment
2019-07-31T19:42:16.567965+00:00 app[web.1]: FROM pg_attribute a
2019-07-31T19:42:16.567966+00:00 app[web.1]: LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2019-07-31T19:42:16.567968+00:00 app[web.1]: LEFT JOIN pg_type t ON a.atttypid = t.oid
2019-07-31T19:42:16.567969+00:00 app[web.1]: LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
2019-07-31T19:42:16.567971+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2019-07-31T19:42:16.567972+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2019-07-31T19:42:16.567973+00:00 app[web.1]: ORDER BY a.attnum
2019-07-31T19:42:16.567975+00:00 app[web.1]: ):
2019-07-31T19:42:16.568064+00:00 app[web.1]: F, [2019-07-31T19:42:16.568002 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5]
2019-07-31T19:42:16.568171+00:00 app[web.1]: F, [2019-07-31T19:42:16.568104 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] app/controllers/sessions_controller.rb:5:in `create'
I have a PostgreSQL add-on installed and it is running. (Otherwise the Rails server wouldn't even boot).
So why do I get this kind of errors on each request? I checked in console and if I do something like User.all I get this :
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist)
LINE 1: SELECT "users".* FROM "users" LIMIT $1
^
: SELECT "users".* FROM "users" LIMIT $1
This gets me so confused, what did I do wrong?
It sounds like you may have run rake db:migrate locally and not on Heroku. As a result, when you use the Heroku CLI, it doesn't recognize the users table because it doesn't yet exist.
I believe if you use have the pg gem in your Gemfile, Heroku's system will automatically setup a database for you. It's been a while since I've created a Heroku instance so don't quote me on that.
If you're unsure if you have PostgreSQL with your app, check the app's service add-ons area. Heroku also has more documentation on using PostgreSQL on their platform. It may be a good idea for you to reference their documentation for getting started with Rails as well.
Once you have your PostgreSQL database setup to work with your app, you use the Heroku CLI to migrate the database and create your users table:
heroku rake db:migrate

Heroku status 500 error after deploying Rails app

$heroku logs --tail
Started GET "/" for 46.188.182.234 at 2016-11-14 20:51:53 +0000
2016-11-14T20:51:53.840163+00:00 app[web.1]: [21c27115-512c-4e9e-bb24-8e1d8b0a46ca] Processing by StaticPagesController#home as HTML
2016-11-14T20:51:53.850654+00:00 app[web.1]: [21c27115-512c-4e9e-bb24-8e1d8b0a46ca] Rendering static_pages/home.html.erb within layouts/application
2016-11-14T20:51:53.856619+00:00 app[web.1]: [21c27115-512c-4e9e-bb24-8e1d8b0a46ca] Rendered static_pages/home.html.erb within layouts/application (5.7ms)
2016-11-14T20:51:53.859704+00:00 app[web.1]: [21c27115-512c-4e9e-bb24-8e1d8b0a46ca] Completed 200 OK in 19ms (Views: 11.1ms | ActiveRecord: 0.0ms)
2016-11-14T20:51:59.479887+00:00 heroku[router]: at=info method=GET path="/signup" host=damp-reef-30485.herokuapp.com request_id=79382bce-34fd-4faa-958c-15b6ce8adf1f fwd="46.188.182.234" dyno=web.1 connect=1ms service=64ms status=500 bytes=1733
2016-11-14T20:51:59.487241+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f] Started GET "/signup" for 46.188.182.234 at 2016-11-14 20:51:59 +0000
2016-11-14T20:51:59.495254+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f] Processing by UsersController#new as HTML
2016-11-14T20:51:59.509968+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f] Completed 500 Internal Server Error in 14ms (ActiveRecord: 1.6ms)
2016-11-14T20:51:59.511411+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f]
2016-11-14T20:51:59.511456+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f] ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
2016-11-14T20:51:59.511457+00:00 app[web.1]: LINE 8: WHERE a.attrelid = '"users"'::regclass
2016-11-14T20:51:59.511457+00:00 app[web.1]: ^
2016-11-14T20:51:59.511458+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2016-11-14T20:51:59.511458+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
2016-11-14T20:51:59.511459+00:00 app[web.1]: (SELECT c.collname FROM pg_collation c, pg_type t
2016-11-14T20:51:59.511459+00:00 app[web.1]: WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),
2016-11-14T20:51:59.511460+00:00 app[web.1]: col_description(a.attrelid, a.attnum) AS comment
2016-11-14T20:51:59.511460+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2016-11-14T20:51:59.511461+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2016-11-14T20:51:59.511461+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2016-11-14T20:51:59.511462+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2016-11-14T20:51:59.511462+00:00 app[web.1]: ORDER BY a.attnum
2016-11-14T20:51:59.511463+00:00 app[web.1]: ):
2016-11-14T20:51:59.511491+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f]
2016-11-14T20:51:59.511536+00:00 app[web.1]: [79382bce-34fd-4faa-958c-15b6ce8adf1f] app/controllers/users_controller.rb:17:in `new'
As you can see I get the home page but when I try to get signup form I got error. Everything is working ok locally, REST actions on users resource are working fine locally.
This output is interesting for me:
"PG::UndefinedTable: ERROR: relation "users" does not exist"
Please help, thanks.
You need to run migrations on Heroku, just run in the shell inside your project:
heroku run rails db:migrate
**This Issue was appeared because of some migration issue.To up migrations in heroku enter below command **
heroku run rake db:migrate
After this,check whether all migrations are up or not.If you get any issue check with that migration.

Too many database connections created in rails 2.3.18 application

We have many models like the below one.
class User < ActiveRecord::Base
create_connection
def create_connection
# we have used this ActiveRecord::Base.configurations[current_environment] for connection_info
self.establish_connection connection_info
end
end
After using many models of similar types, many database connections are being created for the remote database. So we are getting the below error message for remote Postgres database.
2013-12-04T12:18:28.360740+00:00 app[web.1]: FATAL: too many connections for role "ycjcwpowlrmvhi"
Actually we have two applications on heroku and each application accesses the other's database.
How we can close these many database connection after executing the query?
We are also getting the below error some times.
2013-12-06T09:36:27.952787+00:00 app[web.1]: Processing StaffController#index (for 202.45.6.95 at 2013-12-06 09:36:27) [GET]
2013-12-06T09:36:16.453533+00:00 heroku[router]: at=info method=GET path=/javascripts/application.js?1386322453 host=demomanager.herokuapp.com fwd="202.45.6.95" dyno=web.1 connect=1ms service=3ms status=200 bytes=5025
2013-12-06T09:36:32.935950+00:00 app[web.1]:
2013-12-06T09:36:32.935950+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UnableToSend: SSL error: decryption failed or bad record mac
2013-12-06T09:36:32.935950+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
2013-12-06T09:36:32.935950+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-12-06T09:36:32.935950+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-12-06T09:36:32.935950+00:00 app[web.1]: WHERE a.attrelid = '"tags"'::regclass
2013-12-06T09:36:32.935950+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2013-12-06T09:36:32.935950+00:00 app[web.1]: ORDER BY a.attnum
2013-12-06T09:36:32.935950+00:00 app[web.1]: ):
You should be able to change the number of database connections by changing the pool parameter in your database.yml and lowering that value.

we're sorry, but something went wrong on heroku when a user tries signing up [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I can't correctly pinpoint what exactly is causing the issue
This is a new website I just pushed to heroku, ran heroku rake db:migrate, and heroku restart
It works just fine locally but this happens in production
Here's the relevant portion of heroku logs
2013-05-03T23:16:27.189569+00:00 app[web.1]:
2013-05-03T23:16:27.189569+00:00 app[web.1]: Started GET "/signup" for xx.xx.xx.
xxx at 2013-05-03 23:16:27 +0000
2013-05-03T23:16:27.253381+00:00 app[web.1]: Rendered shared/_error_messages.h
tml.erb (0.4ms)
2013-05-03T23:16:27.253381+00:00 app[web.1]: Rendered layouts/_shim.html.erb (
0.0ms)
2013-05-03T23:16:27.253381+00:00 app[web.1]: Rendered layouts/_header.html.erb
(2.9ms)
2013-05-03T23:16:27.253381+00:00 app[web.1]: Processing by UsersController#new a
s HTML
2013-05-03T23:16:27.253381+00:00 app[web.1]: Rendered users/new.html.erb withi
n layouts/application (43.8ms)
2013-05-03T23:16:27.253381+00:00 app[web.1]: Completed 200 OK in 60ms (Views: 48
.4ms | ActiveRecord: 1.6ms | Solr: 0.0ms)
2013-05-03T23:16:27.922135+00:00 heroku[router]: at=info method=GET path=/favico
n.ico host= sleepy-river-xxxx.herokuapp.com fwd="xx.xx.xx.xxx" dyno=web.1 connect
=1ms service=4ms status=304 bytes=0
2013-05-03T23:16:27.268937+00:00 heroku[router]: at=info method=GET path=/signup
host= sleepy-river-xxxx.herokuapp.com fwd="xx.xx.xx.xxx" dyno=web.1 connect=6ms
service=81ms status=304 bytes=0
2013-05-03T23:16:47.934099+00:00 app[web.1]:
2013-05-03T23:16:47.934099+00:00 app[web.1]:
2013-05-03T23:16:47.934099+00:00 app[web.1]: Started POST "/users" for xx.xx.xx.
xxx at 2013-05-03 23:16:47 +0000
2013-05-03T23:16:48.248989+00:00 app[web.1]: Redirected to http://sleepy-river-xxxx.herokuapp.com/home
2013-05-03T23:16:48.248989+00:00 app[web.1]: Parameters: {"utf8"=>"???", "auth
enticity_token"=>"m+NCbnqHJk81yWgyY+Y709mQZ0N04MpW8MLGLXjbleA=", "user"=>{"name"
=>"testuser", "email"=>"testuser#email.com", "password"=>"[FILTERED]", "passwo
rd_confirmation"=>"[FILTERED]"}, "commit"=>"Create my account"}
2013-05-03T23:16:48.248989+00:00 app[web.1]: Completed 302 Found in 311ms (Activ
eRecord: 70.6ms)
2013-05-03T23:16:48.248989+00:00 app[web.1]: Processing by UsersController#creat
e as HTML
2013-05-03T23:16:48.435265+00:00 app[web.1]:
2013-05-03T23:16:48.435265+00:00 app[web.1]:
2013-05-03T23:16:48.435265+00:00 app[web.1]: Started GET "/home" for 75.82.32.16
4 at 2013-05-03 23:16:48 +0000
2013-05-03T23:16:48.649331+00:00 app[web.1]: FROM pg_attribute a L
EFT JOIN pg_attrdef d
2013-05-03T23:16:48.649331+00:00 app[web.1]: WHERE a.attrelid = '"h
ashtags"'::regclass
2013-05-03T23:16:48.649331+00:00 app[web.1]: LINE 4: WHERE a.attrel
id = '"hashtags"'::regclass
2013-05-03T23:16:48.649331+00:00 app[web.1]: ON a.attrelid = d.a
drelid AND a.attnum = d.adnum
2013-05-03T23:16:48.649617+00:00 app[web.1]: 23: <%= link_to "#"+h.hashtag
s, "#" %><br>
2013-05-03T23:16:48.649617+00:00 app[web.1]: 25:
2013-05-03T23:16:48.649845+00:00 app[web.1]: Rendered shared/_user_info.html.e
rb (4.4ms)
2013-05-03T23:16:48.649331+00:00 app[web.1]: ActionView::Template::Error (PGErro
r: ERROR: relation "hashtags" does not exist
2013-05-03T23:16:48.649617+00:00 app[web.1]: 22: <% #htags.each do |h| %>
2013-05-03T23:16:48.649617+00:00 app[web.1]:
2013-05-03T23:16:48.649845+00:00 app[web.1]: Processing by StaticPagesController
#home as HTML
2013-05-03T23:16:48.649331+00:00 app[web.1]:
2013-05-03T23:16:48.649331+00:00 app[web.1]:
^
2013-05-03T23:16:48.649331+00:00 app[web.1]: : SELECT a.attname, for
mat_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
2013-05-03T23:16:48.649617+00:00 app[web.1]: app/views/static_pages/home.html.
erb:22:in `_app_views_static_pages_home_html_erb___3097102804728997358_70437520'
2013-05-03T23:16:48.649845+00:00 app[web.1]:
2013-05-03T23:16:48.649331+00:00 app[web.1]: AND a.attnum > 0 AND
NOT a.attisdropped
2013-05-03T23:16:48.649331+00:00 app[web.1]: ORDER BY a.attnum
2013-05-03T23:16:48.649617+00:00 app[web.1]: 19: <div class="box">
2013-05-03T23:16:48.649617+00:00 app[web.1]: 24: <% end %>
2013-05-03T23:16:48.649617+00:00 app[web.1]: ):
2013-05-03T23:16:48.649617+00:00 app[web.1]: 20: Tagged Posts
2013-05-03T23:16:48.649617+00:00 app[web.1]: 21: <br>
2013-05-03T23:16:48.649845+00:00 app[web.1]: Rendered shared/_stats.html.erb (
38.9ms)
2013-05-03T23:16:48.649845+00:00 app[web.1]: Completed 500 Internal Server Error
in 209ms
2013-05-03T23:16:48.649845+00:00 app[web.1]: Rendered static_pages/home.html.e
rb within layouts/application (156.1ms)
2013-05-03T23:16:48.654562+00:00 heroku[router]: at=info method=GET path=/home h
ost=sleepy-river-xxxx.herokuapp.com fwd="xx.xx.xx.xxx" dyno=web.1 connect=1ms se
rvice=219ms status=500 bytes=643
2013-05-03T23:16:48.253053+00:00 heroku[router]: at=info method=POST path=/users
host= sleepy-river-xxxx.herokuapp.com fwd="xx.xx.xx.xxx" dyno=web.1 connect=3ms
service=395ms status=302 bytes=109
Something is wrong with the template that is loaded after a user signs up. Try it locally, I bet you'll find the answer you need.
Added hint:
Look at the line Relation HashTags does not exist. That holds the key to your problem.
I bet if you run
heroku run rake db:setup
and
heroku run rake db:migrate
Your problem will be solved

Resources