Skip to content

Instantly share code, notes, and snippets.

@adamkirkwood
Created March 6, 2012 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamkirkwood/1989034 to your computer and use it in GitHub Desktop.
Save adamkirkwood/1989034 to your computer and use it in GitHub Desktop.
# Attach the scope as part of a chain in an ActiveRecord query:
UserFacebookFanpages.valid.tracked.find(:all)
class UserFacebookFanpages < ActiveRecord::Base
# ...
# Scopes
scope :valid, where("is_invalid != null OR is_invalid != 0")
scope :invalid, where(:is_invalid => true)
scope :tracked, where(:is_tracked => true)
scope :not_tracked, where(:is_tracked => false)
#...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment