Created
November 7, 2012 08:05
-
-
Save tmikoss/4030121 to your computer and use it in GitHub Desktop.
Rails 3 implementation of .none scope
This file contains hidden or 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 ActiveRecord | |
class Base | |
class << self | |
if respond_to? :none | |
puts "ActiveRecord::Base already has a method 'none'. Remove the implementation from #{__FILE__}" | |
else | |
# In Rails 4 this creates a noop query. Until then, use a query that never returns data. | |
def none | |
where '1=2' | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment