Rails using plural table names even though I told it to use singular
I tried to run rake test:profile
and I got this error:
... Table 'mcif2.accounts' doesn't exist: DELETE FROM `accounts`
I know accounts
doesn't exist. It's called account
.
I know Rails uses plural table names by defaul开发者_C百科t but here's what my config/environment.rb
looks like:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
McifRails::Application.initialize!
ActiveRecord::Base.pluralize_table_names = false
And here's what db/schema.rb
looks like:
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
So I don't understand why Rails still wants to call it accounts
sometimes. Any ideas?
If it helps give any clues at all, here are the results of grep -ir 'accounts' *
.
My guess is that you've named your fixture accounts.yml
or used the directive fixtures :accounts
in one of the performance test. Rails fill the related table using the fixture name without knowledge about the model.
Try to set in your model
set_table_name "account"
精彩评论