Salammobile :: Sms.last
Salammobile :: Sms Load(106.1ms)SELECT sms
。* FROM sms
ORDER BY sms
。oppid
DESC LIMIT 1
ActiveRecord :: SubclassNotFound:单表继承机制无法找到子类:'international'。引发此错误是因为列'type'保留用于在继承的情况下存储类。如果您不打算将其用于存储继承类或覆盖Salammobile :: Sms.inheritance_column以使用另一列来获取该信息,请重命名此列。
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:153:in rescue in find_sti_class'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:147:in
find_sti_class'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:136:in discriminate_class_for_record'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/persistence.rb:53:in
instantiate'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in block in find_by_sql'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in
阻止每个'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in each'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in
每个'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in map'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in
find_by_sql'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/relation.rb:585:in exec_queries'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/relation.rb:471:in
load'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/relation.rb:220:in to_a'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/relation/finder_methods.rb:340:in
find_last'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/relation/finder_methods.rb:123:in last'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-deprecated_finders-1.0.3/lib/active_record/deprecated_finders/relation.rb:146:in
last'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/querying.rb:3:in last'
from (irb):12
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in
start'
来自/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in start'
from /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/railties-4.0.0/lib/rails/commands.rb:64:in
'
来自bin / rails:4:在`require'
答案 0 :(得分:3)
除非用于type
继承机制,否则在Rails中不能有一个名为ActiveRecord
的数据库列。将列重命名为其他内容。
尝试在课程定义中包含此内容:
inheritance_column = "class_type"
这应该会忽略type
列。
答案 1 :(得分:1)
class Salammobile::CountryRate < ActiveRecord::Base
establish_connection("salammobile")
self.table_name = 'smusers'
inheritance_column = :_type_disabled
end
基本上没有工作我正在使用其他服务器上存在的外部数据库,并且应用程序正在使用不同的服务器我现在将此代码设置为正常工作
class Salammobile::CountryRate < ActiveRecord::Base
establish_connection("salammobile")
self.table_name = 'smusers'
self.inheritance_column = nil
end