Question

I saw this on a blog today, and I thought, finally! Rails will have something like HQL or Linq. Um, or not. I couldn't find anything about this.

What I really want to know: will I be able to forget what the tables are called and use the object names only? Can I finally forget join syntax? I'd like to do that before I start forgetting everything else (life goals).

Was it helpful?

Solution

As far as I understand, this means that you can write your complex queries not as

Object.find(:all, :conditions = > { :limit => 10, :offset => 5 }

but more readable way

Object.all.limit(10).offset(5)

OTHER TIPS

Chainable queries with lazy evaluation and the AREL syntax:

This lets you write various scopes representing conditions and then mix and match them and chain them together... in the knowledge the the query will not actually get run until the output is needed ('lazy evaluation').

The syntax of AREL is much closer to standard sql syntax instead of the previous 'rails' syntax so it is easier to use and recognize and maintain for those famiiar with SQL.

You can read more about it here. I'm not terribly familiar with LINQ, but I believe LINQ is somewhat similar to the query interface used by Django's ORM. At any rate, the gist is that the query interface in Active Record is more like that of Django that it was before. A lot of the older "low-level" query methods are deprecated and will be removed in later versions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top