5

I am trying to use Datamapper in a Rails app as an alternative to ActiveRecord.

I've followed the various setup instructions and have Datamapper working in my app.

But one of the first things I noticed that no longer works is this:

  <%= f.error_messages %>

I believe this is tied to an ActiveRecord helper - is there an alternative way of reporting validation failures in the View for Datamapper?

Am I likely to encounter many more examples of functionality like this that will require adjustments in my app?

Is this project doable or is it likely to involve a lot of complicated hackery?

Has anyone documented all of the required application adjustments?

I suspect Datamapper is not used widely because I'm finding it hard to find these kinds of simple instructions on Google.

Baker
  • 53
  • 5
  • Datamapper, from what I've heard, doesn't exactly play nice with Rails, so you'll probably encounter a few more problems. My suggestion, if you're not too far into your application, would be to use Merb. But that's just me. – Sasha Chedygov Jun 07 '09 at 22:52
  • I have no experience getting Datamapper to work in Rails, but I'd like to point out that getting other ORM libraries to work well with Rails is one of the major goals of Rails 3 -- it is likely that most of the pain will be dealt with by the time it is released (whenever that is). – molf Jun 07 '09 at 23:00
  • @musicfreak - Thanks for the suggestion. That's probably a good idea because I'm seeing a lot of examples geared toward Datamapper + Merb. I'm just concerned that I will spend a lot of time learning a new framework and potentially have to postpone starting my app for longer than I can afford to wait. I know this is a hard question to answer because everyone learns at a different rate, but how long would it take you to learn Merb if you had to start from scratch with only a knowledge of Rails? I'm talking about learning it to a level where you can create something useful. – Baker Jun 07 '09 at 23:02
  • @molf - Thanks, yes, I'm aware this is going to a lot easier in Rails 3. Unfortunately I have a deadline for my current project so that's not realistic for my current needs. Still trying to figure out if it's realistic to try to attempt my current project with Datamapper or if I am likely to waste a lot of time needlessly trying to make basic functionality adjust to Datamapper. – Baker Jun 07 '09 at 23:04
  • Merb is very similar to Rails, especially if you use the same templating engine as Rails (erb or whatever it's called). Honestly, it shouldn't take you long at all. It's one of those "you learn as you go along" things. One thing you should note though: Merb's documentation is worse than Rails'. – Sasha Chedygov Jun 07 '09 at 23:46

1 Answers1

3

Today Rails plays well with ActiveRecord; changing ORM will surely give you some troubles. Rails 3.0 will be ORM agnostic so I expect a switch like the one you are describing to be easier in the future.

Unless you are craving to understand Rails inside-out and you are going to have the time to fix the glitches that your application will expose, stick with ActiveRecord.

Am I likely to encounter many more examples of functionality like this that will require adjustments in my app?

It depends on the code you have already wrote. For what you have reported in your question I'd say yes.

Is this project doable or is it likely to involve a lot of complicated hackery?

It is doable and will involve a lot of complicated hackery. The downside is that most of what you are going to learn from this hackery will be likely outdated by Rails 3.0.

lbz
  • 9,560
  • 2
  • 30
  • 35