From ca78ab1901e951ce381eae7089d5d63d95f3fc7c Mon Sep 17 00:00:00 2001 From: Sam Goldman Date: Fri, 28 Apr 2017 17:12:02 -0400 Subject: [PATCH] makes sure you have active record loaded before determining if model is an active record object --- lib/jsonapi/utils/response/formatters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jsonapi/utils/response/formatters.rb b/lib/jsonapi/utils/response/formatters.rb index f3d0db2..f8d3dde 100644 --- a/lib/jsonapi/utils/response/formatters.rb +++ b/lib/jsonapi/utils/response/formatters.rb @@ -22,7 +22,7 @@ def jsonapi_format_errors(data) private def active_record_obj?(data) - data.is_a?(ActiveRecord::Base)|| data.singleton_class.include?(ActiveModel::Model) + defined?(ActiveRecord::Base) && (data.is_a?(ActiveRecord::Base) || data.singleton_class.include?(ActiveModel::Model)) end def build_response_document(records, options)