Sinatra app with ActiveRecord died in Passenger 6.0.5

What are you talking about?

I was running a Sinatra app using ActiveRecord on CentOS 8 + Apache 2.4 + Phusion Passenger 6.0. The version of Ruby is 2.7.1, but maybe this version doesn't really matter.

It worked in Passenger 6.0.4, but in 6.0.6 it doesn't even start in production. It is working properly on hand (local).

The Apache error log (/ var / log / httpd / error_log) showed:

'production' database is not configured. Available: [](ActiveRecord::AdapterNotSpecified)


Apparently it's due to the changes introduced in Passenger 6.0.5. There is an issue here.

Similar problems can occur outside of Sinatra, but not in Rails (probably).

Dead code

The Sinatra app is as simple as searching for and displaying pre-stored data in the SQLite3 database. Database files are not specifically divided into those for production and those for development.

Where the connection is

ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: db_file)

I wrote it like that. The path of the SQLite3 file is assigned to the local variable db_file.


Apparently, I have to set ╩╗ActiveRecord :: Base.configurations`, so I'll do the above

ActiveRecord::Base.configurations = {
  "production" => {"adapter" => "sqlite3", "database" => db_file },
  "development" => {"adapter" => "sqlite3", "database" => db_file },

I changed it like this.

Now it works in production.

Recommended Posts

Sinatra app with ActiveRecord died in Passenger 6.0.5
Decorate your Sinatra app with CSS
Try with resources statement in web app
Implemented pull-down in the original app with Active Hash