#<CreateCorrespondentLoans 的未定义局部变量或方法“correspondent_loans”

undefined local variable or method `correspondent_loans' for #<CreateCorrespondentLoans

我正在使用 rails 4 & ruby 2.0.0.

当我点击 rake db:migrate 时,我得到了错误。它指出 add_index 行有问题。

 ==  CreateCorrespondentLoans: migrating ======================================
-- create_table(:correspondent_loans)
-> 0.0036s
-- correspondent_loans()
rake aborted!
 StandardError: An error has occurred, this and all later migrations canceled:

 undefined local variable or method `correspondent_loans' for #<CreateCorrespondentLoans:

这是代码

    class CreateCorrespondentLoans < ActiveRecord::Migration
 def change
 create_table :correspondent_loans do |t|
  t.string :correspondent
  t.date :purchase_date
  t.decimal :loan_amount, precision: 15, scale: 2
  t.string :curr_status
  t.string :instrument_name
  t.string :loan_id, null: false

  t.timestamps
end

add_index correspondent_loans, loan_id, name: "index_correspondent_loans_loan_id", unique: true, using: :btree
  end
end
class CreateCorrespondentLoans < ActiveRecord::Migration
    def change
        create_table :correspondent_loans do |t|
            t.string :correspondent
            t.date :purchase_date
            t.decimal :loan_amount, precision: 15, scale: 2
            t.string :curr_status
            t.string :instrument_name
            t.string :loan_id, null: false
            t.timestamps
    end
    add_index :correspondent_loans, :loan_id, name: "index_correspondent_loans_loan_id", unique: true, using: :btree
    end
end

correspondent_loans和load_id应该是一个符号。