Receiving Odd Error on Upgrade to Rails 5.2
CodingAnarchy opened this issue · comments
Matt Tanous commented
I have this factory snippet that worked fine on Rails 4.2, but now is breaking as I move to Rails 5.2:
FactoryBot.define do
factory :family_parent do
...
after(:create) do |fp, evaluator|
fp.parent.children.update_all(family_id: fp.family.id)
end
...
end
end
The only other things in this factory are boolean flags, and I am not creating it directly - it is created by the family
The error I am receiving is very vague and I'm at a loss as to where it could be coming from, so here is the stack trace:
Failure/Error: fp.parent.children.update_all(family_id: fp.family.id)
NoMethodError:
undefined method `extending' for #<Array:0x00007ffcc9e7a9c8>
Did you mean? extend
# ./spec/factories/family_parents.rb:10:in `block (3 levels) in <top (required)>'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callback.rb:14:in `instance_exec'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callback.rb:14:in `run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callbacks_observer.rb:11:in `block in update'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callbacks_observer.rb:10:in `each'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callbacks_observer.rb:10:in `update'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/evaluation.rb:24:in `notify'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy/create.rb:13:in `block in result'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy/create.rb:9:in `tap'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy/create.rb:9:in `result'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/factory.rb:43:in `run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/factory_runner.rb:28:in `run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/factories/families.rb:31:in `block (3 levels) in <top (required)>'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callback.rb:14:in `instance_exec'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callback.rb:14:in `run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callbacks_observer.rb:11:in `block in update'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callbacks_observer.rb:10:in `each'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/callbacks_observer.rb:10:in `update'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/evaluation.rb:24:in `notify'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy/create.rb:13:in `block in result'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy/create.rb:9:in `tap'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy/create.rb:9:in `result'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/factory.rb:43:in `run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/factory_runner.rb:28:in `run'
# /Users/vision/.rvm/gems/ruby-2.5.1/gems/factory_bot-4.8.2/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/models/family_parent_spec.rb:37:in `block (3 levels) in <top (required)>'
# ./spec/models/family_parent_spec.rb:38:in `block (3 levels) in <top (required)>'
# ./spec/models/family_parent_spec.rb:42:in `block (4 levels) in <top (required)>'
# ./spec/models/family_parent_spec.rb:41:in `block (3 levels) in <top (required)>'
Any help would be much appreciated. Thanks.
Matt Tanous commented
Turns out I had an -> { uniq }
on a scope, and that converted to an array with Rails 5. This error was just spectacularly unhelpful at discovering that issue.
Just thought I would let anyone who stumbled on this know.