我的db模式有點問題。 我已經創建了一個名爲messages
的遷移,但它並不好,所以我刪除了它們以替換好的messages
遷移。 但在我的模式中,我有最後的messages
遷移。Rails:遷移不起作用
怎麼可能?
軌分貝:遷移:狀態:
up 20160924085640 Create conversations
up 20160924090519 Create messages
schema.rb:
create_table "conversations", force: :cascade do |t|
t.integer "sender_id"
t.integer "recipient_id"
end
create_table "messages", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "subject"
t.string "body"
t.integer "recipient_id"
t.integer "sender_id"
end
遷移:
class CreateMessages < ActiveRecord::Migration[5.0]
def change
create_table :messages do |t|
t.text :body
t.references :conversation, index: true
t.references :user, index: true
t.boolean :read, :default => false
t.timestamps
end
end
end
路線
resources :conversations do
resources :messages
end
當我嘗試進入/對話
我有這樣的錯誤:uninitialized constant ConversationsController
當您嘗試訪問'/'對話,這意味着它將搜索'index' 'ConversationsController.rb'方法。你的'ConversationsController.rb'丟失。這不是遷移問題。 – Emu
是的,它是另一個問題^^但爲什麼我沒有在我的shema和遷移文件中相同的遷移? – alex
class ConversationsController
alex