I\'m using active_model_serializers gem to control the serialization data, and seeing some odd behavior. My code looks like so:
@Gagan this works for me:
App.users = new App.Collections.Users(<%= ActiveModel::ArraySerializer.new(@users).to_json.html_safe %>);
You are not using your serializer in the HTML view. Try this:
App.users = new App.Collections.Users(<%= UserSerializer.new(@users).to_json.html_safe %>);
The reason for this is that the serializer is picked up in the respond_with
method, the serializer does not overwrite your .to_json
method.