Created
January 13, 2015 23:38
-
-
Save tiagoamaro/49465ee23a1924cb15df to your computer and use it in GitHub Desktop.
Rails many-to-many self-join
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
| # as described in http://guides.rubyonrails.org/association_basics.html#self-joins | |
| class User < ActiveRecord::Base | |
| has_and_belongs_to_many :friends, | |
| class_name: "User", | |
| foreign_key: "this_user_id", | |
| association_foreign_key: "other_user_id" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment