更改类型时未定义的方法after_update

时间:2018-08-17 14:35:27

标签: ruby-on-rails ruby-on-rails-5 sti

更新子类的类型时出现一个奇怪的问题。从4迁移到Rails 5时开始发生这种情况。

sortablejsOptionsBuckets: SortablejsOptions = {
  animation: 150,
  group: {
    name: 'board',
    put: true,
    pull: true
  },
  handle: '.bucket-drag-handle',
}

如果我这样更改TextFieldAttribute的类型,则:

<div class="drag-handle">
  <span>Element can be dragged here but not in the input</span>
  <input type="text" class="exclude-drag">
</div>

我明白了

class TextFieldAttribute < MyAttribute
end

class TextAreaAttribute < MyAttribute
end

class MyAttribute < ApplicationRecord
  after_update :do_something
end

似乎正在查看TextFieldAttribute实例是否响应after_update,而不是该类。这是Rails 5 STI的错误吗?

0 个答案:

没有答案
相关问题