rails-api/active_model_serializers — pull request #645 by gauthier-delacroix (2014-09-08 12:10:28+00:00)
Title: Fix namespaced serializers reloading

As discussed (https://github.com/rails-api/active_model_serializers/pull/617#issuecomment-54798433) with @konukhov, some namespaced serializers aren't found anymore after a reload in development mode.

Note sure if it's Rails related but this PR adds a fallback `safe_constantize` when `#const_get` doesn't find a matching serializer in the parent tree. This is more like a workaround but it actually works fine.

As `safe_constantize` returns nil if the class is not found, I've moved the `begin...rescue NameError` in `_const_get` so it's not necessary anymore to add it in methods depending on it.