Created
March 10, 2016 17:04
-
-
Save derwiki/f0c7214eff7d872c1176 to your computer and use it in GitHub Desktop.
Overriding `default_scope` in `has_many` `through` association.
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 Website < ActiveRecord::Base | |
| default_scope { where.not(is_private: true) } | |
| end |
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 WebsiteScreenshot < ActiveRecord::Base | |
| Website.unscope(where: :is_private) do | |
| belongs_to :website | |
| has_many :website_follows, through: :website | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment