Skip to content

Instantly share code, notes, and snippets.

@jcasimir
Created December 14, 2011 17:51
Show Gist options
  • Save jcasimir/1477661 to your computer and use it in GitHub Desktop.
Save jcasimir/1477661 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :residencies
has_many :states, :through => :residencies
def peers
Residency.where(:state_id => self.state_ids).include(:users).users
end
end
class State < ActiveRecord::Base
has_many :residencies
has_many :users, :through => :residencies
end
class Residency < ActiveRecord::Base
belongs_to :user
belongs_to :state
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment