Skip to content

Instantly share code, notes, and snippets.

@tmikoss
Created November 7, 2012 08:05
Show Gist options
  • Save tmikoss/4030121 to your computer and use it in GitHub Desktop.
Save tmikoss/4030121 to your computer and use it in GitHub Desktop.
Rails 3 implementation of .none scope
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