Rails 500 Error: "We're sorry, but something went wrong."

After three nights on this issue and reading all the posts about it, I must finally ask this question!

I want to deploy the simplest Rails application for Heroku:

rails new test_appli cd test_appli git init git add . git commit -m "initial commit" heroku create git push heroku master 

Everything is fine, the application works well on Heroku. After that I will create the SQLite3 database:

 rails generate scaffold User name:string email:string rake db:migrate 

Everything is OK on the local computer. I can clearly see localhost:3000/users . Then I want to put the database on Heroka. First I modify my gemfile:

 group :production do gem 'pg' end group :development, :test do gem 'sqlite3' end 

Then I send it all to Geroku:

 git init git add . git commit -m "with Database" git push heroku master heroku rake db:migrate 

Then there are no errors in the package, everything is in order, the database is sent, but an error appears on the heroku.com/users page

Rails 500, "Sorry, but something went wrong"

I don’t know what to do anymore. Can you help me?

+6
source share
7 answers

I suspect you are trying to deploy a Rails 3.1 application on a bamboo stack (heroku creates the default settings on a bamboo stack 1.9.2 and does not start Rails 3.1 out of the box). The cedar stack is much better for Rails 3.1 sites -

to try

 heroku create --stack cedar 

when creating your application on Heroku and cancel it. Also note that your rake team at Heroku will become

 heroku run rake db:migrate 
+7
source

Do:

heroku run rake db: schema: load

I had the same problem. It works for me after git push heroku master

+3
source

Do not run git init in the second set of commands - you only need to initialize the git repository once.

Also, it looks great - do you see any errors somewhere?

0
source

Why are you using pg stone in your production group, but sqlite3 stone in your development group? It seems to me that your problem is most likely due to the fact that you are working with another database that you use in a production environment. If I were you, I would stick to one that would facilitate its debugging.

If you really need / need the application to work as soon as possible, just launch it during the creation process using sqlite ... Gemfile:

 gem 'rails' gem 'sqlite3' 

In addition, a quick way to find out what the error is is to run heroku logs from the unix console.

0
source

What version of Rails? Can you try creating an application running on the Cedar stack?

 heroku create myapp --stack cedar 

Given that the application runs on cedar, you need to slightly modify the commands, for example:

 heroku run rake db:migrate 

In any case, you really need to check your logs, because your problem may not even be database related, but asset related.

0
source

Do you have an added database instance with a heroku common number? When you create your heroku application (on cedar), it does not necessarily automatically create a database.

 airlift:projects $ heroku create --stack cedar testapp9 Creating testapp9... done, stack is cedar http://testapp9.herokuapp.com/ | git@heroku.com :testapp9.git airlift:projects $ heroku addons --app testapp9 logging:basic releases:basic 

When you look at the heroku configuration, you get nothing:

heroku config

 airlift:projects $ heroku config --app testapp9 airlift:projects $ 

To add a database:

heroku addons: add shared database: 5mb

 airlift:projects $ heroku addons:add shared-database:5mb --app testapp9 -----> Adding shared-database:5mb to testapp9... done, v3 (free) airlift:projects $ heroku config No app specified. Run this command from an app folder or specify which app to use with --app <app name> airlift:projects $ heroku config --app testapp9 DATABASE_URL => postgres://blah: blah@blah.compute-1.amazonaws.com /blah SHARED_DATABASE_URL => postgres://blah: blah@blah.compute-1.amazonaws.com /blah airlift:projects $ 

Then you must migrate your db.

0
source

Hi, thanks for helping me find a way to connect to my postgres database on Heroku, however, being new to Heroku and postgresql, I had to redesign what blah is. Therefore, I believe that I will break it to help others when you helped me.

Postgres: // [user]: [password] @ [server_name] .compute-1.amazonaws.com / [base]

0
source

Source: https://habr.com/ru/post/901069/


All Articles