Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can DataMapper still be used for Rails?

Tags:

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?

like image 312
Jonah Avatar asked Aug 09 '13 19:08

Jonah


2 Answers

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' 
like image 110
Abe Voelker Avatar answered Oct 28 '22 23:10

Abe Voelker


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 :)

like image 25
Andrew Hacking Avatar answered Oct 29 '22 00:10

Andrew Hacking