私はRailsのガイドを読んでいたと私は、コードのこれらの行が見つかりました:移行のt.references対モデルのbelongs_to?
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.string :commenter
t.text :body
t.references :post
t.timestamps
end
add_index :comments, :post_id
end
end
は私もマイケル・ハートル氏の著書、Railsのチュートリアルを読んで、私は上記のコードで使用される「t.references」については何も見つかりませんでした。 どうしますか?マイケルの本では、モデルではhas_manyとbelongs_to関係を使用し、マイグレーションでは何もしません(イベントt.belongs_toではなく)。
@stackoverflow.com/questions/7788188/what-is-the-difference-between-t-belongs-to-and-t-references-in-railsの可能な複製 – sameers
@sameersは実際にはありません他の人は、モデルにないマイグレーションの中の 'belongs_to'について質問しています –