我的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