Know what errors lurk in your code? Rollbar detects and alerts you when code breaks in production. Get the stack trace, code, and data to help you d̶e̶b̶u̶g̶ defeat Ruby errors. Learn more.

RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

[Experimental] Repository Pattern on top of ActiveRecord

Over the past few days I’ve started experimenting with the idea of implementing the repository pattern on top of ActiveRecord (yes, it sounds scary). The motivation came after we were about to kick start a relatively large scale system. It would be great to retain the powerfulness of ActiveRecord as well as making our app easier to maintain and test. It is basically a compromise, a stop gap, if you will.

I’ve always liked the Datamapper library but unfortunately ever since the Merb/Rails merge it has stepped outside of the spotlight. Datamapper 2 is shaping up nicely but it is still a far way away. So I decided to base my experimentation on top of utilising both ActiveRecord and Virtus, the attributes component of Datamapper 2.

You can check out what I’ve been doing here:

It is an experiment, and it’s still too early to see how useful and practical it’ll become, but I’d love to get some feedback from you guys!


You can use DataMapper with Rails 3 using dm-rails.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in