rails-api/active_model_serializers — pull request #397 by changa (2013-10-08 10:05:52+00:00)
Title: Fix `#as_json` glitch caused by JSON and Rails

This should solve rails-api/active_model_serializers#340.

When requiring Rails, `as_json` somehow ends up with a
JSON::Ext::Generator::State instance as arguments, instead of a plain old Hash,
which causes this:

```
2.0.0 (main):0 > require "active_model_serializers"
=> true
2.0.0 (main):0 > require "json"
=> true
2.0.0 (main):0 > JSON.dump ActiveModel::Serializer.new(Object.new)
=> "\"#\""
2.0.0 (main):0 > require "rails"
=> true
2.0.0 (main):0 > JSON.dump ActiveModel::Serializer.new(Object.new)
NoMethodError: undefined method `fetch' for #
from /home/drr/code/af/map/code/.bundle/ruby/2.0.0/gems/active_model_serializers-0.8.1/lib/active_model/serializer.rb:341:in `as_json'`'`
```