Build factories for self referential associations in rails
问题 I have a typical requirement, I have to address user object as follows user.referrer and user.referrers. Basically, user can refer more than one person and one person should be referred by one particular user. So I build associations as follows. They are working great. class User < ActiveRecord::Base attr_accessible :account_number, :display_name, :referrer_id has_many :referrers, :class_name => "User", :foreign_key => "referrer_id" belongs_to :referrer, :class_name => "User" end Now I would