I'm sorry if this has been posted before already. I wasn't sure how to word my question so I wasn't sure that I was searching on the right thing.
Basically, my question is, how do I create a has_one relationship where the reference key is an id on the table that is defining the relationship. Probably better explained as an example:
Table has an admin_role_id and a user_role_id. so I am looking to do something like
has_one :admin_role, class_name: 'Role, ... has_one :user_role, class_name: 'Role, ...
that '...' is the part I can't seem to figure out. I am not sure what I need to define so that the model knows to look for the role id based on the local tables admin_role_id or user_role_id.
I am trying to avoid having to create a method in the model that looks up the role in the following way:
def admin_role Role.find_by(id: admin_role_id) end
Any thoughts are greatly appreciated.