Ensure generator picks up ApplicationSerializer

ApplicationSerializer could exist, but not be loaded. So, we check
existence by looking at the filesystem instead of defined?.

Fixes https://github.com/rails-api/active_model_serializers/issues/1890
This commit is contained in:
Lee Richmond
2016-09-05 09:48:06 -04:00
parent 1dc2b74059
commit 3f16b75a68
3 changed files with 24 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ module Rails
def parent_class_name
if options[:parent]
options[:parent]
elsif defined?(::ApplicationSerializer)
elsif 'ApplicationSerializer'.safe_constantize
'ApplicationSerializer'
else
'ActiveModel::Serializer'