rails 迁移错误“参数数量错误”

问题描述 投票:0回答:1

无法迁移,面临此错误 StandardError:发生错误,此迁移和所有后续迁移均已取消:

Caused by:
ArgumentError: wrong number of arguments (given 2, expected 1)
/home/ciaranmurphy/cashanalytics/db/migrate/20130614160852_add_first_name_last_name_user_type_values_to_user.rb:3:in `change'
/home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:32:in `block (2 levels) in <top (required)>'
/home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:18:in `block in migrate_each'
/home/ciaranmurphy/cashanalytics/app/services/tenant.rb:132:in `with_public'
/home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:16:in `migrate_each'
/home/ciaranmurphy/cashanalytics/lib/tasks/multitenant.rake:31:in `block in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

尝试了迁移和跟踪,但没有解决问题

ruby-on-rails migration trace rspec-rails
1个回答
0
投票

没有实际的迁移文件很难说,但请确保您的

cashanalytics/db/migrate/20130614160852_add_first_name_last_name_user_type_values_to_user.rb
文件看起来像这样:

Class AddFirstNameLastNameUserTypeValuesToUser < ActiveRecord::Migration
  def change
    add_column :user, :first_name, :string
    add_column :user, :last_name, :string
    # guessing the data type here
    add_column :user, :type, :integer
  end
end
© www.soinside.com 2019 - 2024. All rights reserved.