-3

我知道在 SO 上有很多关于这个主题的问题,但它们似乎都不是我的案例的解决方案。所以,我希望有人能提供帮助。

当我运行迁移时,我收到以下错误:

CreateEvents: migrating 
-- create_table(:events)
   -> 0.0558s
-- add_index(:events)
rake aborted!
An error has occurred, this and all later migrations canceled:

wrong number of arguments (1 for 2)

我不知道我在寻找什么以及在哪里。我想将我的用户表更改为注册表。

注册控制器:

class RegistrationsController < ApplicationController
end

注册型号:

class Registration < ActiveRecord::Base
  attr_accessible :email, :password_digest
end

注册迁移:

class CreateRegistrations < ActiveRecord::Migration
  def change
    create_table :registrations do |t|
      t.string :email
      t.string :password_digest

      t.timestamps
    end
  end
end

架构.rb:

ActiveRecord::Schema.define(:version => 20130825195829) do

  create_table "activities", :force => true do |t|
    t.integer  "trackable_id"
    t.string   "trackable_type"
    t.integer  "owner_id"
    t.string   "owner_type"
    t.string   "key"
    t.text     "parameters"
    t.integer  "recipient_id"
    t.string   "recipient_type"
    t.datetime "created_at",     :null => false
    t.datetime "updated_at",     :null => false
  end

  add_index "activities", ["owner_id", "owner_type"], :name =>      "index_activities_on_owner_id_and_owner_type"
  add_index "activities", ["recipient_id", "recipient_type"], :name => "index_activities_on_recipient_id_and_recipient_type"
  add_index "activities", ["trackable_id", "trackable_type"], :name => "index_activities_on_trackable_id_and_trackable_type"

  create_table "comments", :force => true do |t|
    t.string   "commenter"
    t.text     "body"
    t.integer  "event_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "comments", ["event_id"], :name => "index_comments_on_event_id"

  create_table "events", :force => true do |t|
    t.string   "title"
    t.text     "text"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end
end
4

1 回答 1

1

add_index需要 2 个参数示例:add_index :events, :title

于 2013-10-13T06:22:08.430 回答