Created
September 28, 2013 03:35
-
-
Save bachue/6738086 to your computer and use it in GitHub Desktop.
ActiveRecord 测试复杂的关系
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 | |
has_and_belongs_to_many :followees, class_name: 'User', foreign_key: 'follower_id', association_foreign_key: 'follow_id', :join_table => 'follows' | |
has_and_belongs_to_many :followers, class_name: 'User', foreign_key: 'follow_id', association_foreign_key: 'follower_id', :join_table => 'follows' | |
has_many :followers_comments, through: :followers, :source => :comments | |
has_many :comments | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment