{"action":"created","issue":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1540","repository_url":"https://api.github.com/repos/rails-api/active_model_serializers","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1540/labels{/name}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1540/comments","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1540/events","html_url":"https://github.com/rails-api/active_model_serializers/issues/1540","id":136709592,"number":1540,"title":"Serialize nested elements on post and put request","user":{"login":"sagits","id":6174566,"avatar_url":"https://avatars.githubusercontent.com/u/6174566?v=3","gravatar_id":"","url":"https://api.github.com/users/sagits","html_url":"https://github.com/sagits","followers_url":"https://api.github.com/users/sagits/followers","following_url":"https://api.github.com/users/sagits/following{/other_user}","gists_url":"https://api.github.com/users/sagits/gists{/gist_id}","starred_url":"https://api.github.com/users/sagits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagits/subscriptions","organizations_url":"https://api.github.com/users/sagits/orgs","repos_url":"https://api.github.com/users/sagits/repos","events_url":"https://api.github.com/users/sagits/events{/privacy}","received_events_url":"https://api.github.com/users/sagits/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/Question","name":"Question","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-26T14:15:11Z","updated_at":"2016-03-02T05:13:02Z","closed_at":null,"body":"Hi, how can i use nested objects instead of passing an id in a post/put request?\r\n\r\nI would like to do something like this:\r\n\r\n```\r\nPOST /products\r\n\r\n{\r\n\"name\": \"Notebook Dell x500\", \r\n\"category\" : {\r\n                    \"id\": \"10\"\r\n                    \"name\" : \"Electronics\"\r\n                   }\r\n}\r\n```\r\n\r\n\r\nIs this possible? Thanks in advance."},"comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments/191066115","html_url":"https://github.com/rails-api/active_model_serializers/issues/1540#issuecomment-191066115","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1540","id":191066115,"user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T05:13:02Z","updated_at":"2016-03-02T05:13:02Z","body":"If you're on 0.10.0.rc4 sounds like you'd want to use the Attributes adapter and a Serializer something like\r\n\r\n```ruby\r\nclass ProductSerializer < ActiveModel::Serializer\r\n  attributes :name\r\n  has_one :category\r\nend\r\nclass CategorySerializer < ActiveModel::Serializer\r\n  attributes :id, :name\r\nend\r\n```\r\n\r\nand then in you're controller you'd `render json: product, adapter: :attributes` and you'd see it render the JSON document\r\n\r\n\r\n```json\r\n{\r\n  \"name\": \"Notebook Dell x500\", \r\n  \"category\" : {\r\n    \"id\": \"10\",\r\n    \"name\": \"Electronics\"\r\n  }\r\n}\r\n```\r\n\r\nAt this time, AMS does not include its own params parser, but the mapping your suggesting can be pretty easily handled:\r\n\r\n```http\r\nPATCH /products HTTP/1.1\r\n\r\n{\r\n  \"products\":  { \"name\": \"Notebook Dell x500\", \"category\": { \"id\": \"10\", \"name\": \"Electronics\"}}\r\n}\r\n```\r\n"}}