0
我有以下兩種模式:下面的Rails模型應該如何在續集中看起來像?
class Dispute < ApplicationRecord
belongs_to :accuser, class_name: 'User', optional: true
belongs_to :defendant, class_name: 'User', optional: true
end
class User < ApplicationRecord
end
下面是Dispute
遷移:
class CreateDisputes < ActiveRecord::Migration[5.0]
def change
create_table :disputes do |t|
t.references :accuser
t.references :defendant
end
end
end
這是他們的言行舉止中的Rails:
Dispute.first.accuser
# => <# User>
Dispute.first.defendant
# => <# User>
在續集,我m應該是to use many_to_one
,但這是否意味着Sequel User
模型應該有相應的one_to_many
?似乎無法得到它的工作。