耙子流产了!未初始化的常量CreateConversationsSummaries

时间:2013-11-07 17:07:54

标签: sql ruby-on-rails

我在运行rake aborted! uninitialized constant CreateConversationsSummaries时收到rake:db migrate。我正在尝试使用SQL来聚合对话的信息。

我的迁移:

class CreateConversationSummaries < ActiveRecord::Migration
  def up
    execute <<-SQL
      CREATE VIEW conversation_summaries AS
        SELECT c.id,
        s.name as sender_name,
        r.name as recipient_name
        FROM conversations c
        inner join users r on r.id = c.recipient_id
        inner join users s on s.id = c.sender_id
    SQL
  end

  def down
    execute 'DROP VIEW conversation_summaries'
  end
end

它可能与我以前的迁移发生冲突吗?

class CreateConversations < ActiveRecord::Migration
  def change
    create_table :conversations do |t|
      t.string :sender_id
      t.string :recipient_id
      t.string :subject

      t.timestamps
    end
  end
end

1 个答案:

答案 0 :(得分:1)

我猜移动文件的名称与类的名称有所不同,但我不记得在这种情况下通常会看到未初始化的常量错误。检查迁移文件的名称是否包含在其中的类名的驼峰版本。

目前,请求的常量CreateConversationsSummaries与您的迁移CreateConversationSummaries中定义的内容,复数与单数对话之间似乎存在差异。

相关问题