class CreateMatches < ActiveRecord::Migration
def self.up
create_table :matches do |t|
t.integer :result_home
t.integer :result_away
t.references :clan, :as => :clan_home
t.references :clan, :as => :clan_away
t.references :league
t.timestamps
end
end
def self.down
drop_table :matches
end
end
コードはすべてをクリアすると思います。result_home を 1 つのクランに参照し、result_away を別のクランに参照する必要があります。そうするための最良の方法は何ですか?has_and_belongs_to_many を作成できましたが、この場合は良い方法ではないと思います。