I have a model in rails, lets say User, which i want to have a relation to another user.
User A, can be the boss of User B and User B can be the boss of User C and D.
This relation is a one-to-many. One user can stand above multiple users.
How would i do this.
My user model has currently an ID with the name boss_id, which will be nil if the user is in the top of the food chain.
My active record class looks like this:
class User < ActiveRecord::Base
has_many :users #People beneath the user
belongs_to :user
end
But now I want to use relation with a name. Lets say boss and followers.
How can I achieve this?
Here’s how it would look like: