I want to self-referentiate a model in a RoR app but, I don\'t know exactly how. I want to save a linked list where the next node has the id of the previous one. how can I d
I've spent some time trying to make it work using Rails 3.2.14
The documentation's suggestion for self-joining associations hasn't worked for belongs_to
associations. Adding a foreign key fixed the issue.
Class User < ActiveRecord::Base
has_many :invitees, class_name: 'User', foreign_key: :invited_by
belongs_to :host, class_name: 'User', foreign_key: :invited_by
end