From 88b5a86dc335167beb8cf2936b2d7613c483985f Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 28 Mar 2017 13:26:59 -0700 Subject: [PATCH] Set belongs_to_required_by_default = false As of Rails 5, belongs_to is now required by default. Our models, including those in extensions and applications, aren't ready for this. In Rails 5.0 there seems to be some bug that was preventing this new default from affecting Spree::Base models. > Spree::Base.belongs_to_required_by_default => nil > config.active_record.belongs_to_required_by_default => true In Rails 5.1 this seems to be fixed so we need to be explicit about what we use. We might as well be explicit in Rails 5.0 anyways. --- core/app/models/spree/base.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/app/models/spree/base.rb b/core/app/models/spree/base.rb index c4f4bf42285..a413e7745ee 100644 --- a/core/app/models/spree/base.rb +++ b/core/app/models/spree/base.rb @@ -4,6 +4,8 @@ class Spree::Base < ActiveRecord::Base include Spree::RansackableAttributes + self.belongs_to_required_by_default = false + def initialize_preference_defaults if has_attribute?(:preferences) self.preferences = default_preferences.merge(preferences)