检查记录时在控制台中发生错误

Salammobile :: Sms.last

Salammobile ::短信加载(106.1ms)选择sms *从sms ORDER BY smsoppid DESC LIMIT 1 ActiveRecord :: SubclassNotFound:单表继承机制未能找到子类:'international'。 出现此错误的原因是“类型”列在保留继承的情况下保留用于存储类。 如果您不打算将其用于存储继承类或覆盖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'from /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 /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0/lib/active_record/querying 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实例化。 rb:45:在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块中每个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/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 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 /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'from /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 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' 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 /usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/activerecord-4.0.0 /lib/active_record/querying.rb:3:in last'from 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从/usr/local/rvm/gems/ruby-1.9.3-p448@salamPlanet/gems/railties-4.0.0/lib/rails/commands/console.rb开始:9: 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'


除非用于ActiveRecord继承机制,否则不能在Rails中包含名为type的数据库列。 将该列重命名为其他内容。

尝试在你的班级定义中包括这个:

inheritance_column = "class_type"

这应该使其忽略type列。


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
链接地址: http://www.djcxy.com/p/49727.html

上一篇: Getting error in console when checking the record

下一篇: Rails single table inheritance with lowercase type names