I have multiple models with created_by and modified_by columns. This is what I have for a Deal Model.
class Deal has_one :user , :foreign_key => 'created_by' has_one :user , :foreign_key => 'modified_by' end
class User belongs_to :created_by , :class_name => 'Deal' , :foreign_key => 'created_by' belongs_to :modified_by , :class_name => 'Deal' , :foreign_key => 'modified_by' end
When I create the deal, looks like it is saving correctly. But in the show view when I try to get @deal.created_by.email I get undefined method email error. Can some tell me how to get this working please?
Also since I have multiple models with these two colums, there can be many belongs_to in User model. Is there an elegant solution for this case.
Thanks DM