Top "Arel" questions

Arel is a Relational Algebra for Ruby.

Rails where condition using NOT NIL

Using the rails 3 style how would I write the opposite of: Foo.includes(:bar).where(:bars=>{:id=>nil}) …

ruby-on-rails rails-activerecord arel
Combine two ActiveRecord::Relation objects

Suppose I have the following two objects: first_name_relation = User.where(:first_name => 'Tobias') # ActiveRecord::Relation last_name_…

ruby-on-rails rails-activerecord arel
How to do a LIKE query in Arel and Rails?

I want to do something like: SELECT * FROM USER WHERE NAME LIKE '%Smith%'; My attempt in Arel: # params[:…

ruby-on-rails activerecord arel
How do you scope ActiveRecord associations in Rails 3?

I have a Rails 3 project. With Rails 3 came Arel and the ability to reuse one scope to build another. I …

ruby-on-rails activerecord ruby-on-rails-3 named-scope arel
Want to find records with no associated records in Rails

Consider a simple association... class Person has_many :friends end class Friend belongs_to :person end What is the cleanest …

ruby-on-rails arel meta-where
Subqueries in activerecord

With SQL I can easily do sub-queries like this User.where(:id => Account.where(..).select(:user_id)) This produces: …

ruby-on-rails-3.1 subquery arel
Multiple CTE in single query

Is it possible to combine multiple CTEs in single query with arel? I am looking for way to get result …

sql postgresql common-table-expression recursive-query arel
ActiveRecord Arel OR condition

How can you combine 2 different conditions using logical OR instead of AND? NOTE: 2 conditions are generated as rails scopes and …

sql ruby-on-rails ruby activerecord arel
How to use unscoped on associated relations in Rails3?

I have a default scope on products due to information security constraints. class Product < ActiveRecord::Base has_many :photos …

ruby-on-rails ruby-on-rails-3 scope arel
Best way to find a single record using ActiveRecord 3 / Arel?

Where I used to do this: Foo.find_by_bar('a-value') I can now do this: Foo.where(:bar => …

ruby-on-rails ruby activerecord arel