错误的参数数量(1对2)

时间:2013-10-13 05:32:16

标签: ruby-on-rails ruby ruby-on-rails-3

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

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

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)

我不确切地知道我在寻找什么以及在哪里。我想将我的Users表更改为Registrations表。

注册控制器:

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

Schema.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

1 个答案:

答案 0 :(得分:1)

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