Rails 4.2 and Active Model Serializer


Updated to 4.2 and now I cannot for the life of me get the AMS configuration to work correctly.

ActiveModel::Serializer.setup do |config|
  config.embed = :ids
  config.embed_in_root = true

Previously, this worked great with:

respond_with @thing

With 4.2 (and 0.9.2 AMS), you have to say:

respond_with @thing, root: true

explicitly. Anyone understand why the global config no longer works?


I have had similar issues, what are you getting on the receiving end? A debugging console, such as the one built in to Chrome, should give you the payload coming back from the server. One trick I have had to do is set the root key manually,

render json: @thing, root: "thing"


Are you using the responders gem? In rails 4.2 they ‘removed’ respond_with (sort of) - see http://edgeguides.rubyonrails.org/4_2_release_notes.html#respond-with-class-level-respond-to

I am still on rails 4.1 and have not tried the responders gem yet.


0.9.1 had some regressions so they re-released 0.9.0 as 0.9.2. The fix for Rails 4.2 is in 0.9.1 and in the 0.8.x branch, but not in 0.9.2. So I locked to 0.9.1 for now. What a hot mess!