[Rails] Introducing Datamappify - ActiveRecord Without DB Migrations

Introduction

ActiveRecord is without doubt the de facto ORM library for Rails and many Ruby web frameworks. Many developers however, do not like database migrations and prefer to use DSL for data mapping. Datamappify is created with the sole purpose of getting rid of the DB migration headaches.

Why Not DB Migrations?

Well, depending on your specific project, DB migrations might create more trouble than it’s worth. Besides, your code is already version controlled, so why create a separate version control for your DB schema?

Why Not Use DataMapper, Sequel, etc?

As stated in the introduction, ActiveRecord is the most popular ORM in the rails community, it is actively developed and battle-tested. If your only grief with ActiveRecord is the DB migrations, why not just eliminate it be happy? ;)

Go check out the code!

[Rails Tip] DataMapper M:M Association Bug and Workaround

It was confirmed that DataMapper is incorrectly setting table names in SQL JOINs.

So for instance, the following code would generate an SQL error:

type.jobs.all(:"country.name".like => "%#{params[:location]}%")

There is a workaround, however the workaround requires manual looping of the dataset thus produces N+1 queries.

type.jobs.all.reject do |job|
  ! job.country.name.downcase.include?(params[:location].downcase)
end

But at least it works. ;)