Can DataMapper still be used for Rails?
Asked Answered
H

5

21

I'm looking to use a more separated system for my models in a Ruby on Rails project. It looked like the solution was DataMapper. However, I see that none of their repositories have been updated in the last year, and when installed in a Rails 4 project, it has gem version dependency conflicts with newer Gems. Searching doesn't turn up any content on using it with Rails 4.

What is its state now? Should I use it, or something else?

Hoofer answered 9/8, 2013 at 19:3 Comment(0)
P
29

As someone who uses DataMapper every day at my job, I would recommend sticking to ActiveRecord unless you are connecting to a legacy database that you don't control the schema of (but I would also consider Sequel if that were the case). Beyond the fact that it is EOL (as a maintainer stated on the mailing list), many gems that need model persistence will support ActiveRecord but it's very rare that they will support DataMapper, so expect to implement support yourself. In my experience if I find a bug I know I will also have to fix it myself due to the low usage / abandonment of DataMapper.

As danmanstx mentioned, the maintainers are mostly focused on Ruby Object Mapper (ROM) now, which used to be DM2. Although some pieces of ROM are feature-complete, it still doesn't have a release date AFAIK (see the roadmap).

If you look at the release-1.2 branch of the relevant DM gems, you can see that it does get minor updates every once in a while. However, there is a backlog of hundreds of issues across the DataMapper gems, many over 2 years old that simply won't be addressed because there just aren't enough DataMapper maintainers (and I don't blame them for wanting to work on something new!).

You're right about the latest RubyGems versions of DM gems having versioning conflicts. If you want to use the latest stable version of DM, I'd advise using the release-1.2 branch of the DM gems you need, e.g.

gem 'dm-core', git: 'git://github.com/datamapper/dm-core.git', branch: 'release-1.2'
Palmerpalmerston answered 9/8, 2013 at 21:54 Comment(1)
Excellent answer, thanks @Abe. I think I've successfully implemented the Domain Model/Data Mapper patterns on top of ActiveRecord. It would be nice if something this simple was supported by Rails. * shrug *Hoofer
P
12

You really should take a look at Sequel if you're considering DataMapper, FWIW I will be migrating away from ActiveRecord to Sequel.

However if you like the opinionated Rails ideology then you shouldn't look any further than ActiveRecord for least friction.

With no disrespect to the hard work of the Rails community and developers, but after dealing with the evolution of scopes, association conditions, relations vs associations, nested attributes, record initialisation, string based ordering clauses, search strings, hashes and arel,inability to express and compose queries easily or reuse scopes effectively, validation of related model bugs, parent vs child association building weirdness, poor documentation and none of it gelling together nicely, you may too decide to move to a clearly better thought out ORM like Sequel.

Similarly you may look at the ideology of Rails (being unabashedly opinionated), and consider what might fit better if you prefer choice and a conceptually cleaner approach in a modern web framework. Rails 4 was the last hoorah for me, hello Sinatra/Padrino/Sequel, Postgres/Redis/Solr and Backbone/Marionette/Eco/Coffeescript ... my opinionated web development framework :)

Protestation answered 20/8, 2013 at 7:47 Comment(0)
L
3

DataMapper was changed to DataMapper2 and then changed to ruby object mapper.

it can be found here https://github.com/rom-rb/rom

Legitimate answered 9/8, 2013 at 19:17 Comment(2)
So it's not a useable project for now?Hoofer
ROM depends heavily on multiple gems. The developers are usually working on those, rather than in ROMLatitudinarian
R
3

At my work we ran into many problems with DataMapper. Eventually after much research and talking to developers I realised it was a dead-end project. I documented the reasons we decided to abandon it here:

http://opensourceame.com/why-we-abandoned-ruby-datamapper/

Raynaraynah answered 12/2, 2014 at 10:29 Comment(0)
T
1

There is another gem to achieve DataMapper decoupling in Ruby. It called Datamappify.

Another nice projects is under development and needs help: Virtus, rom-rb and Sequel (already mentioned in this thread).

It's important that Rubyists study and try other approach to do software with Ruby. We have Padrino.rb, Grape, Rack and so on.

Triggerfish answered 21/11, 2013 at 12:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.