Skip to content

Instantly share code, notes, and snippets.

@anoldguy
Last active December 14, 2015 17:39
Show Gist options
  • Select an option

  • Save anoldguy/5124001 to your computer and use it in GitHub Desktop.

Select an option

Save anoldguy/5124001 to your computer and use it in GitHub Desktop.
Rails Scope Blocks
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