Writing Drivers for ActiveRecord (Rails 3)

How to write custom database drivers for Rails 3? I mean to write, for example, the MongoDB driver, so it can be used without any changes in the models and using different stones, such as MongoID and MongoMapper. Thank!

+3
source share
1 answer

Writing a driver is not easy, but as a rule, it’s best to look at several other drivers, break them into the necessary items, and create a backup by filling in the blanks.

ActiveRecord comes with Postgres, MySQL, SQLite3, and SQLite adapters, so you can write your own using them as examples. They are in lib/active_record/connection_adaptersand they are all based on a common abstract adapter.

You may have trouble trying to write a wrapper for a non-SQL database, where ActiveRecord offers many suggestions about what tools have a basic storage engine.

+3
source

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


All Articles