Created
March 14, 2011 23:04
-
-
Save bcurren/870047 to your computer and use it in GitHub Desktop.
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
class Model < ActiveRecord::Base | |
default_scope order("title desc") | |
scope :with_city, lambda { |city| where("city = ?", city) } | |
def self.search | |
# How do I do this? Need to remove a relation | |
self.scoped.remove(self.default_scoping).all | |
end | |
end | |
Model.with_city('San Francisco').search # What I want -> select * from models where city = 'San Francisco' | |
class Model < ActiveRecord::Base | |
default_scope order("title desc") | |
scope :with_city, lambda { |city| where("city = ?", city) } | |
def self.search | |
self.unscoped.all | |
end | |
end | |
Model.with_city('San Francisco').search # Not what I want -> select * from model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment