Ruby on Rails Getting started with Ruby on Rails Create a new Rails app with a non-standard database adapter

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Rails is shipped by default with ActiveRecord, an ORM (Object Relational Mapping) derived from the pattern with the same name.

As an ORM, it is built to handle relational-mapping, and more precisely by handling SQL requests for you, hence the limitation to SQL databases only.

However, you can still create a Rails app with another database management system:

  1. simply create your app without active-record
$ rails app new MyApp --skip-active-record
  1. add your own database management system in Gemfile
gem 'mongoid', '~> 5.0'
  1. bundle install and follow the installation steps from the desired database.

In this example, mongoid is an object mapping for MongoDB and - as many other database gems built for rails - it also inherits from ActiveModel the same way as ActiveRecord, which provides a common interface for many features such as validations, callbacks, translations, etc.

Other database adapters include, but are not limited to :

  • datamapper

  • sequel-rails



Got any Ruby on Rails Question?