Skip to content

Instantly share code, notes, and snippets.

@JonRowe
Created March 15, 2012 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonRowe/2044768 to your computer and use it in GitHub Desktop.
Save JonRowe/2044768 to your computer and use it in GitHub Desktop.
Replicate problem with uniq associations
class User < ActiveRecord::Base
has_and_belongs_to_many :followers, :class_name=>'User', :foreign_key=>'follower_id', :association_foreign_key=>'user_id', :join_table=>'followers_users', :uniq=>true
has_and_belongs_to_many :followings, :class_name=>'User', :foreign_key=>'user_id', :association_foreign_key=>'follower_id', :join_table=>'followers_users', :uniq=>true
end
ActiveRecord::Schema.define(:version => 20120315142037) do
create_table "users", :force => true
create_table "followers_users", :force => true do |t|
t.integer 'user_id'
t.integer 'follower_id'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment