gpt4 book ai didi

ruby-on-rails - Rails 使用复数表名,即使我告诉它使用单数

转载 作者:搜寻专家 更新时间:2023-10-30 19:52:03 24 4
gpt4 key购买 nike

我尝试运行 rake test:profile,但出现了这个错误:

... Table 'mcif2.accounts' doesn't exist: DELETE FROM `accounts`

我知道 accounts 不存在。它称为帐户

我知道 Rails 默认使用复数表名,但这是我的 config/environment.rb 的样子:

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
McifRails::Application.initialize!

ActiveRecord::Base.pluralize_table_names = false

下面是 db/schema.rb 的样子:

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

create_table "account", :force => true do |t|
t.integer "customer_id", :limit => 8, :null => false
t.string "account_number", :null => false
t.integer "account_type_id", :limit => 8
t.date "open_date", :null => false

所以我不明白为什么 Rails 有时仍要将其称为 accounts。有什么想法吗?

如果它有助于提供任何线索,heregrep -ir 'accounts' * 的结果。

最佳答案

我的猜测是您已将夹具命名为 accounts.yml 或在其中一项性能测试中使用了指令 fixtures :accounts。 Rails 在不知道模型的情况下使用夹具名称填充相关表。

关于ruby-on-rails - Rails 使用复数表名,即使我告诉它使用单数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4693192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com