Last active
September 24, 2015 01:16
-
-
Save thauanz/ae2ab4ddfc7d8f749d1e to your computer and use it in GitHub Desktop.
Blacklist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Blacklist | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def where_blacklist(query) | |
where(query) | |
end | |
end | |
def self.included(r) | |
r.extend ClassMethods | |
end | |
end | |
class Client < ActiveRecord::Base | |
belongs_to :club | |
end | |
class Club < ActiveRecord::Base | |
include Blacklist | |
has_many :clients | |
end | |
Club.where_blacklist("clients.id NOT IN (1,2,3,4)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment