Deploying a databaseless Ruby on Rails application on dokku!

While developing a web-app, there might be some times that you just need a landing page a page that just informs people that you are in the process of creating something great!.

In those instances a database might not be needed, usually what happens you may have created a database and linked it to the application, since most likely you have PostgreSQL selected as the production database and if not configured the application container will not start since the connection will fail.

What if we actually want to deploy without the database?, is ActiveRecord really required in a rails application at which no migrations or data are pushed to a database?

Lets begin with the Gemfile, since we do not need the database lets remove both sqlite3 and pg gems, this will ensure that these gems will not be installed in our production machine once deployed.


By editing the Gemfile the changes are not reflected at the Gemfile.lock, in order to update the Gemfile.lock just run the bundle install command.

Ok, great so far we have ensured that nothing related to databases (external gems) will not be installed. How about ActiveRecord?.

By default and as per the conventions Rails requires all railties, we can also choose which ones to require. Therefore we need to comment out the “require ‘rails/all” and add the#

require ‘action_controller/railtie’
require ‘action_mailer/railtie’
require ‘active_model/railtie’
require ‘sprockets/railtie’
require ‘rails/test_unit/railtie’

Furthermore since the ActiveRecord is not really loaded due to the changes we need to eliminate all calls to it since will likely raise an exception. Therefore we also comment out the config.active_record.migration_error = :page_load



As per the rails guides just about every Rails application will interact with a database. You can connect to the database by setting an environment variable ENV['DATABASE_URL'] or by using a configuration file called config/database.yml.

Using the config/database.yml file you can specify all the information needed to access your database.

In our case we have no database therefore we don’t really need the configuration file, the file was created automatically as per the conventions, since we already violated the conventions we can assume its safe to delete the config/database.yml.

There are some other calls towards the active record that need to be commented out in order to avoid any unforeseen exceptions,one under config/environments/production.rb and one under config/environments/development.rb

At production.rb we need to comment out config.active_record.dump_schema_after_migration = false and at development.rb the config.active_record.migration_error = :page_load.



That should be it!.

In case you have created a database and linked it using dokku, ensure that the database container is deleted before pushing the changes to the remote repository.

(dokku postgresql:delete <db> Delete specified PostgreSQL container)

Some useful links for further reading:


dokku Project:

PostgreSQL plugin for Dokku:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.