¶ ↑
Active Record OR clause - proof-of-conceptNOTE: This is a proof-of-concept project.
If you are serious about using “OR” clauses with ActiveRecord, take a look at Squeel instead.
¶ ↑
How it worksLet’s assume you have the following scopes:
scope :johnes, where(:first_name => "John") scope :smiths, where(:last_name => "Smith")
Once you require “lib/ar_or_where” file, you can combine the scopes like this:
User.johnes.or(User.smiths) => SELECT "users".* FROM "users" WHERE (("users"."first_name" = 'John' OR "users"."last_name" = 'Smith'))
Please find the example in spec/models/user_spec.rb