Im tryign to update a model of mine so that it will have a created_by and updated_by field. Looking into some questions and answers here, it seems I don't have the same problem as them.
My TestCase model should have a created_by and updated_by foreign key, but it should both be a User class. Is that possible?
something like:
belongs_to :user, :foreign_key => 'created_by'
belongs_to :user, :foreign_key => 'updated_by'
Keep in mind that created by and updated_by can 开发者_如何学JAVAbe different(meaning another user can edit the testcase)
Try to use:
belongs_to :creator, :class_name => "User", :foreign_key => 'created_by'
belongs_to :updater, :class_name => "User", :foreign_key => 'updated_by'
You should refer to that objects through:
item.creator
item.updater
精彩评论