jnicklas/carrierwave — pull request #832 by ayamomiji (2012-09-09 07:56:36+00:00)
Title: work with active_model_serializers

Hi, I'm using active_model_serializers to serialize my models to json,
my serializer just like this:

~~~ ruby
class UserSerializer < ActiveModel::Serializer
attributes :id, :username, :avatar # avatar is an uploader
end
~~~

and i expect the output should be:

~~~ json
{
"user": {
"id": 1,
"username": "ayamomiji",
"avatar": {
"url": "/assets/avatar.jpeg",
"thumb": {
"url": "/assets/thumb-avatar.jpeg"
}
}
}
}
~~~

but it was:

~~~ json
{
"user": {
"id": 1,
"username": "ayamomiji",
"avatar": {
"avatar": {
"url": "/assets/avatar.jpeg",
"thumb": {
"url": "/assets/thumb-avatar.jpeg"
}
}
}
}
}
~~~

it nested with an unnecessary key (avatar), so i just patch to remove it.