Adds chaining scopes with 'or'
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 4 commits behind woahdae:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
README.md
Rakefile
active_record_or.gemspec

README.md

ActiveRecord OR

Let's say you were trying to implement a SOPA enforcement tool:

class Blog < ActiveRecord::Base
  has_one :author
  ...
  scope :infringing,         where("artist_mentions_count > 0")
  scope :main_competition,   where("competition_rank > 7")
  scope :generally_disliked, where("subjective_dislike_rating > 3")
  ...
end

This would let you write handy things like

to_blacklist = Blog.infringing.or.main_competition.or.generally_disliked
to_harass    = Blog.joins(:author).where('authors.name' => 'Julian')\
                                  .or.generally_disliked

The end.

Credits

Gem extracted from (i.e. mostly sponsored by) http://www.hfa3.org/

TODO

Dispite the name of the gem, I'll probably add not logic also. Seems like or and not are really all that's missing from AR scopes.