module ActiveRecord
  module Coders
    class NestedHstore < Hstore
      def initialize(default=nil)
        super(default)
        @nested_serializer = ::NestedHstore::Serializer.new
      end

      private

      def to_hstore obj
        super(@nested_serializer.serialize(obj))
      end

      def from_hstore hstore
        if ActiveRecord::VERSION::MAJOR >= 4
          @nested_serializer.deserialize(hstore)
        else
          @nested_serializer.deserialize(super)
        end
      end
    end
  end
end

module ActiveRecord
  module Coders
    class NestedHstore < Hstore
      def initialize(default=nil)
        super(default)
        @nested_serializer = ::NestedHstore::Serializer.new
      end

      private

      def to_hstore obj
        super(@nested_serializer.serialize(obj))
      end

      def from_hstore hstore
        if ActiveRecord::VERSION::MAJOR >= 4 && hstore.is_a?(Hash)
          @nested_serializer.deserialize(hstore)
        else
          @nested_serializer.deserialize(super)
        end
      end
    end
  end
end

Fix compatibility issue with paper_trail, from_hstore gets called with a string even on AR4
Fix compatibility issue with paper_trail, from_hstore gets called with a string even on AR4