Skip to content

Commit

Permalink
Define preferences attribute only when used
Browse files Browse the repository at this point in the history
Since rails/rails@7b39197 serialezable hash attributes are not allocated
by default anymore if not used.
  • Loading branch information
filippoliverani committed Dec 21, 2020
1 parent c7025ee commit b947015
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions core/app/models/spree/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
class Spree::Base < ActiveRecord::Base
include Spree::Preferences::Preferable
include Spree::Core::Permalinks
serialize :preferences, Hash

include Spree::RansackableAttributes

def initialize_preference_defaults
Expand All @@ -18,6 +16,7 @@ def initialize_preference_defaults
def self.preference(*args)
# after_initialize can be called multiple times with the same symbol, it
# will only be called once on initialization.
serialize :preferences, Hash
after_initialize :initialize_preference_defaults
super
end
Expand Down

0 comments on commit b947015

Please sign in to comment.