我不知道我錯過了什麼 - 我最近將我的Product
類別從靜態枚舉移到了表中,所以我需要修改引用。Rails 5遷移 - 缺少的參考
我會結合我的許多移民是建立Tasks
表,我需要有對Product
表的引用現在
class CreateTasks < ActiveRecord::Migration[5.1]
def change
create_table :tasks do |t|
t.string :task_name
t.text :comment
t.datetime :task_start_date
t.datetime :task_end_date
t.references :project
t.timestamps
end
end
end
class AddDocumentsToTasks < ActiveRecord::Migration[5.1]
def change
add_reference :tasks, :document, foreign_key: true
add_reference :tasks, :product, foreign_key: true
end
end
class AddClientIdToTasks < ActiveRecord::Migration[5.1]
def change
add_foreign_key :tasks, :client, foreign_key: true
end
end
的新鮮模式(減少)
我實際上並不知道t.integer "product"
來自任務文件夾。我已經看遍了。
它是目前打破所有集成/播種因爲一個警告,如: ActiveRecord::AssociationTypeMismatch: Product(#69974683871240) expected, got 1 which is an instance of Integer(#13017840)
我想這是很簡單的東西,我失蹤,但因爲它是非常多餘的代碼我不太知道爲什麼它的工作原理對於文檔/項目,而不是產品。
以防萬一: 產品遷移
class CreateProducts < ActiveRecord::Migration[5.1]
def change
create_table :products do |t|
t.string :product_name
t.text :product_description
t.references :client
t.references :task
t.timestamps
end
end
末**
更新
不回答這個問題,直到我完全理解爲什麼,但似乎我誤解了rails db:reset
做。一旦我放棄/創建/遷移/種子一步一步地完成整個數據庫結構,並且新模式發生。
它似乎db:重置是只有使用我的Schema.rb文件中的邏輯。
你的問題還在嗎? –