josevalim/active_model_serializers — Issue #3: Awkward to use association objects and association ids at the same time.
Author: Adman65
Created: 2011-12-05 10:26:29+00:00
State: open

I'm using this project in my application. I have classes that should return serialized objects and some that only only return the id's. At this point you can get around it by saying `attributes :account_id` then specifying `has_one` or `has_many`. I'm proposing a change to the API that would make it easier for this situation to work. Here is my proposed change:

```ruby
class UserSerializer < ActiveModel::Serializer
has_many :contacts, :as => :objects
belongs_to :account, :as => :id
end
```

The `embed` could set the preference, but I'm not sure how that would work. I am interested in adding this functionality and will gladly write a pull request if you guys thing this is a good thing to do.