rails class reminders belongs_to creator code example
Example 1: rails class reminders belongs_to creator
class Task < ActiveRecord::Base
belongs_to :soldier
belongs_to :creator, class_name: Soldier, foreign_key: :created_by
end
class Soldier < ActiveRecord::Base
has_many :tasks
has_many :created_tasks, class_name: Task, foreign_key: :created_by
end
Example 2: rails class reminders belongs_to creator
class Task < ActiveRecord::Base
belongs_to :soldier
belongs_to :creator, class_name: 'Soldier', foreign_key: :created_by
end