我無法爲使用STI的表加載燈具。Rails:無法爲使用STI的表加載燈具(未定義方法`reflect_on_all_associations')
當我打電話FIXTURES=schools rake db:fixtures:load
,我得到這個錯誤:
undefined method `reflect_on_all_associations' for Object:Class
- 其他附着物加載罰款,即
FIXTURES=committes rake db:fixtures:load
- 夾具通過調用
rake db:fixtures:extract
創建這裏是我的學校遷移:
class CreateSchools < ActiveRecord::Migration
def self.up
create_table :schools do |t|
t.string :name
t.string :type
t.string :street
t.string :city
t.string :province
t.timestamps
end
end
...
end
我有幾個模型文件,即school.rb
:
class School < ActiveRecord::Base
end
而且secondary_school.rb
:
class SecondarySchool < School
end
這裏的堆棧跟蹤:
undefined method `reflect_on_all_associations' for Object:Class
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:597:in `insert_fixtures'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:568:in `each'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:568:in `insert_fixtures'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:512:in `create_fixtures'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:512:in `each'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:512:in `create_fixtures'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:510:in `create_fixtures'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/connection_adapters/mysql_adapter.rb:267:in `disable_referential_integrity'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:501:in `create_fixtures'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/base.rb:1482:in `silence'
/home/loranaw/ruby/gems/gems/activerecord-2.3.10/lib/active_record/fixtures.rb:500:in `create_fixtures'
/home/loranaw/ruby/gems/gems/rails-2.3.10/lib/tasks/databases.rake:223
/home/loranaw/ruby/gems/gems/rails-2.3.10/lib/tasks/databases.rake:222:in `each'
/home/loranaw/ruby/gems/gems/rails-2.3.10/lib/tasks/databases.rake:222
和一些示例陽明:
---
schools_7133:
city: Nahanni Butte
name: Charles Yohin School
created_at: 2010-11-26 02:36:39
grade_range: K-10
latitude: "61.03349"
country: CA
updated_at: 0000-00-00 00:00:00
postal_code: "X0E 0N0"
url:
street: ""
id: "9682"
type: SecondarySchool
fax: (867) 602-2202
phone: (867) 602-2200
funding:
longitude: "-123.38642"
school_type:
province: NT
email:
我正在使用STI。 Type正被用於存儲SecondarySchool,PrimarySchool等。 – 2010-12-10 04:34:59