0
我在Ryan Bates的[Railcast] [1]之後重新安裝了Rails 3.1 RC。看來,每個STI實現都會拋出相同的錯誤(如下所述)。對於其他每個型號,都不會出現問題。STI是否仍然與Rails 3.1 RC不兼容?
這是一個已知的問題?一個錯誤可能?或者在我的結尾有什麼缺失?任何人遇到同樣的錯誤?
媒體模型是STI。事件模型從媒體模型繼承。模型定義:
class Media < ActiveRecord::Base
belongs_to :user
....
end
class Event < Media
...
end
在控制檯上,我做的:
ruby-1.9.2-p136 :009 > Event.count
Creating scope :page. Overwriting existing method Event.page.
ActiveRecord::StatementInvalid: PGError: ERROR: relation "media" does not exist
LINE 4: WHERE a.attrelid = '"media"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"media"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:958:in `async_exec'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:958:in `exec_no_cache'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:547:in `block in exec_query'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:222:in `block in log'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:217:in `log'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:546:in `exec_query'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:1057:in `column_definitions'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:736:in `columns'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:93:in `block (2 levels) in initialize'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:174:in `with_connection'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:90:in `block in initialize'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:104:in `yield'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:104:in `default'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:104:in `block in initialize'
from /Users/Chris/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:709:in `yield'
... 8 levels...
from /Users/Chris/Sites/site_name.1/app/models/event.rb:1:in `<top (required)>'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:452:in `load'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:452:in `block in load_file'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:451:in `load_file'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:338:in `require_or_load'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:489:in `load_missing_constant'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:181:in `block in const_missing'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:179:in `each'
from /Users/Chris/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc1/lib/active_support/dependencies.rb:179:in `const_missing'
from (irb):9
from /Users/Chris/.rvm/gems/[email protected]/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:44:in `start'
from /Users/Chris/.rvm/gems/[email protected]/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:8:in `start'
from /Users/Chris/.rvm/gems/[email protected]/gems/railties-3.1.0.rc1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require' from script/rails:6:in
[1]: http://railscasts.com/episodes/265-rails-3-1-overview
你有名爲「type」的列嗎? – Arsen7 2011-05-24 14:01:44
Yeap,有那個專欄 – 2011-05-24 18:25:46