Last active
December 14, 2015 17:39
-
-
Save anoldguy/5124001 to your computer and use it in GitHub Desktop.
Rails Scope Blocks
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 User < ActiveRecord::Base | |
| # New way recommended by rails | |
| has_many :membership_seasons, -> { uniq }, :through => :season_memberships, :source => :season | |
| # The Deprecated Way, which seems much easier to read | |
| has_many :membership_seasons, :through => :season_memberships, :source => :season, :uniq => true | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment