Rails4 -> Rails5 のアップデートでActiveModel::MissingAttributeError
で引っかかる。
Rails5にアップデートしたところ、FactoryGirl
がActiveModel::MissingAttributeError
を出してしまっていた。
最初はなんだかよくわかっていなかったが、どうにもdefault_value_for
を利用しているmodelが死んでいるようだった。
Pull Requestは既に出ているが、今のところ取り込まれてない(2016/07/08現在)
どうすれば? -> Rails5で導入されたActiveRecord attributeを使う。
Modelのデフォルト値はattributeで対応出来る。
なので、こんな感じのコードを
class SomeModel < ActiveRecord::Base
default_value_for :is_public, false
end
こうするだけで良くなった。
class SomeModel < ActiveRecord::Base
attribute :some_flag, :boolean, default: -> { false }
end