How to configure Ruby on Rails with no database?

Viewed 73344

It would be convenient to use Ruby on Rails for a small website project that has no current need for a database. I know I could create an empty database in MySQL and go from there, but does anyone know a better way to run Rails without a database?

Thanks

6 Answers

Uncomment this line in the environment.rb file:

config.frameworks -= [ :active_record, :active_resource, :action_mailer]

If you don't need a database then you probably don't need to have the bulk of Rails. You may want a smaller more customizable framework to work with.

Sinatra is a tiny framework that is great for serving up basic static pages.

But if you insist on using Rails here is an article that will show you how to do just that or here.

For support Rails 6 rc1 and activerecord-nulldb-adaptergem we need a monkey patching

In config/initializers/null_db_adapter_monkey_patches.rb

module ActiveRecord
  module ConnectionAdapters
    class NullDBAdapter < ActiveRecord::ConnectionAdapters::AbstractAdapter
      def new_table_definition(table_name = nil, is_temporary = nil)
        TableDefinition.new(table_name, is_temporary)
      end
    end
  end
end
Related