create_table :authors do |t|
t.string :name
t.timestamps
end
create_table :books do |t|
t.belongs_to :author
t.datetime :published_at
t.timestamps
end
end
end
Hello, why we don't declare author_id in books table?
We do in "belongs_to" line
_id is concatenated to author automatically?
How else would it belong to in database migration?
Обсуждают сегодня