views:

1078

answers:

4

I understand that it is a replacement for ActiveRecord and that it uses objects instead of queries.

But...

why is this better?

will objects/queries be "easier" to create?

will it lead to more efficient SQL queries?

will it be compatible with all major DBs? - I assume it will.

will it be easier/harder to use with stored procedures?

+28  A: 
Jörg W Mittag
Excellant answer. I had read the link you posted and followed it for the most part. In fact the comp sci part made sense but how it was incorporated into rails was where I was having the problems. It makes much more sense to me that it replaces the hand-crafted SQL(or whatever) and thus that AR is built on top of it in 3.0. I had been getting different impressions for people who should know better and this answer is brilliant in its simple and precise explanation of each question above.
Will
I do have one follow up question. You mentioned LDAP, AMZ, etc. above, I assume that currently (based on rails/arel on github) ARel does not have that capability, just the potential? i.e. until someone implements that part. This does sound super exciting though.
Will
@Will - I think you're going to have to wait for someone to develop those funkier capabilities. Or take a crack at one yourself, should you need it?
Mike Woodhouse
+3  A: 

Unfortunately i don't have enough karma yet to post this as a comment (hooray stupid karma systems)

ARel, is unfortunately tied directly to generating SQL and thus is unsuitable for DataMapper's needs.

The way i would put it is that ARel is an explicit query model for ActiveRecord that generates and optimizes SQL queries for RDBMSes.

DataMapper on the other hand is a genuine mapper for data, and can interface with non-relational data stores already. In the future DataMapper is likely to include a separate library called Veritas, which is intended to provide relational functionality to data sourced from ANY data store, not just RDBMSes.

knowtheory
Why did this receive -1?
Jeriko
I am the maintainer of DataMapper, and what knowtheory says is true.ARel, in it's current implementation, cannot be used underneath DataMapper because it only provides a subset of the functionality needed to work with the 40+ datastores that DM supports. IMHO the current implementation is tightly coupled to SQL generation, and it will take alot of work to fix the API/internals to work with datastores substantially different from an RDBMS.ARel is a step forward, but it can't form a foundation for more than ActiveRecord at the moment.
dkubb
+1  A: 

Actually I have started a video series on ActiveRelation.

The first general tutorial can be viewed at http://Innovative-Studios.com/#pilot

Snuggs
+1 I liked the video. It could be a bit longer though :)
Will
+1  A: 

Ariel in Rails 3 makes relation objects where the db isn't queried until you need it. Much more efficient.

It's also more natural (once you get used to it) which is really the great strength of Rails.

BServiss