rails-api/active_model_serializers — pull request #462 by fab (2013-12-03 05:41:31+00:00)
Title: Generator now properly detects if ApplicationSerializer exists

Today I discovered that the gem supports the use of an ApplicationSerializer file that the other serializers can inherit from.

However, using the generator to create new serializers didn't have them inheriting from ApplicationSerializer like desired. It looks like the #defined? method wasn't working as intended. (It returned nil unless I had already typed ::ApplicationSerializer into the console).

What I've proposed might not be the best way to do this but I can confirm that it works.

There isn't an issue filed for this because I thought it would be a better use of resources to just provide a fix.

Thoughts?

I'm also happy to edit the docs to point out the use of ApplicationSerializer. It's a great place to extract a method that appears in all your serializers. (Had this exact use case today)