Last active
December 26, 2015 11:29
-
-
Save tamalw/7144185 to your computer and use it in GitHub Desktop.
Can I use "reverse" scopes on an instance to keep it DRY?
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 Article < ActiveRecord::Base | |
scope :published, -> { where("draft = false AND publish_at <= ?", Time.now) } | |
end | |
foo = Article.find(123) | |
foo.published? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment