Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 迁移期间使用了错误的STI列_Ruby_Ruby On Rails 3 - Fatal编程技术网

Ruby 迁移期间使用了错误的STI列

Ruby 迁移期间使用了错误的STI列,ruby,ruby-on-rails-3,Ruby,Ruby On Rails 3,在新的迁移中,我尝试添加一列并填充其值: def up add_column :topics, :status, :string Topic.reset_column_information Topic.find_each do |t| if t.ended? t.status = 'ended' end end Topic.reset_column_information end 我不知道为什么,但在添加

在新的迁移中,我尝试添加一列并填充其值:

  def up
    add_column :topics, :status, :string
    Topic.reset_column_information
    Topic.find_each do |t|
      if t.ended?
        t.status = 'ended'
      end
    end
    Topic.reset_column_information
  end
我不知道为什么,但在添加列之后,在Topic.find_期间,出现了以下异常:

单表继承机制无法定位子类:“其他”

我的主题模型确实声明了以下内容:

  self.inheritance_column = 'class_name'

因此,我不确定为什么它仍然尝试使用type列查找STI子类。

我发现,一旦我删除了
重置列信息,问题就消失了

    add_column :topics, :status, :string
    # Topic.reset_column_information
    Topic.find_each do |t| ...
reset\u column\u information
在删除STI列设置时可能存在错误