Skip to content

Commit 40d6655

Browse files
committed
Merge pull request #645 from gauthier-delacroix/Fix-namespaced-serializers-reloading
Fix namespaced serializers reloading
2 parents 6054080 + e273fc5 commit 40d6655

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/active_model/serializable/utils.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ module Utils
44
extend self
55

66
def _const_get(const)
7-
method = RUBY_VERSION >= '2.0' ? :const_get : :qualified_const_get
8-
Object.send method, const
7+
begin
8+
method = RUBY_VERSION >= '2.0' ? :const_get : :qualified_const_get
9+
Object.send method, const
10+
rescue NameError
11+
const.safe_constantize
12+
end
913
end
1014
end
1115
end

lib/active_model/serializer.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ def serializer_for(resource, options = {})
6363
ArraySerializer
6464
end
6565
else
66-
begin
67-
_const_get build_serializer_class(resource, options)
68-
rescue NameError
69-
nil
70-
end
66+
_const_get build_serializer_class(resource, options)
7167
end
7268
end
7369

0 commit comments

Comments
 (0)