Getting error in console when checking the record

Salammobile::Sms.last

Salammobile::Sms Load (106.1ms) SELECT sms .* FROM sms ORDER BY sms . oppid DESC LIMIT 1 ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'international'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Salammobile::Sms.inheritance_column to use another column for that information. from /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 instantiate' from /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 block 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 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/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' from /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' from /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 /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 last' from /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' from /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 ' from bin/rails:4:in `require'


You can't have a database column called type in Rails unless it's being used for ActiveRecord inheritance mechanism. Rename the column to something else.

Try including this at your class definition:

inheritance_column = "class_type"

This should make it ignore the type column.


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/49728.html

上一篇: 红宝石在轨道上

下一篇: 检查记录时在控制台中发生错误