{"action":"created","issue":{"url":"https://api.github.com/repos/stefankroes/ancestry/issues/213","labels_url":"https://api.github.com/repos/stefankroes/ancestry/issues/213/labels{/name}","comments_url":"https://api.github.com/repos/stefankroes/ancestry/issues/213/comments","events_url":"https://api.github.com/repos/stefankroes/ancestry/issues/213/events","html_url":"https://github.com/stefankroes/ancestry/issues/213","id":48037901,"number":213,"title":"Serialization options to include/except attributes with arrange_serializable","user":{"login":"ArTiSTiX","id":1231011,"avatar_url":"https://avatars.githubusercontent.com/u/1231011?v=3","gravatar_id":"","url":"https://api.github.com/users/ArTiSTiX","html_url":"https://github.com/ArTiSTiX","followers_url":"https://api.github.com/users/ArTiSTiX/followers","following_url":"https://api.github.com/users/ArTiSTiX/following{/other_user}","gists_url":"https://api.github.com/users/ArTiSTiX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArTiSTiX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArTiSTiX/subscriptions","organizations_url":"https://api.github.com/users/ArTiSTiX/orgs","repos_url":"https://api.github.com/users/ArTiSTiX/repos","events_url":"https://api.github.com/users/ArTiSTiX/events{/privacy}","received_events_url":"https://api.github.com/users/ArTiSTiX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-11-07T01:36:09Z","updated_at":"2015-05-12T00:30:09Z","closed_at":null,"body":"I'm currently having some difficulties with arrange_serializable.\r\nI eager load some of relations of the hierarchical model... but there seems to be no options to add those fields in serialization...\r\n\r\nI'm doing:\r\n\r\n```ruby\r\nMyModel.first.subtree.select(:id,:ancestry,:user_id).includes(:user).arrange_serializable\r\n```\r\n\r\nBut user relation is not serialized.\r\nI expect something like:\r\n```json\r\n{\r\n  \"id\": 1, \"ancestry\": null, \"user_id\": 1,\r\n  \"user\": {\"id\": 34, \"name\": \"John Doe\"},\r\n  \"children\": [\r\n    {\r\n      \"id\": 2, \"ancestry\": \"1\", \"user_id\": 2,\r\n      \"user\": {\"id\": 32, \"name\": \"Chuck Norris\"},\r\n      \"children\": []\r\n    },\r\n    {\r\n      \"id\": 4, \"ancestry\": \"1\", \"user_id\": 2,\r\n      \"user\": {\"id\": 32, \"name\": \"Chuck Norris\"},\r\n      \"children\": []\r\n    }\r\n  ]\r\n}\r\n```\r\nAny practice to do this with arrange_serializable ?\r\n"},"comment":{"url":"https://api.github.com/repos/stefankroes/ancestry/issues/comments/101081522","html_url":"https://github.com/stefankroes/ancestry/issues/213#issuecomment-101081522","issue_url":"https://api.github.com/repos/stefankroes/ancestry/issues/213","id":101081522,"user":{"login":"mastfish","id":1920407,"avatar_url":"https://avatars.githubusercontent.com/u/1920407?v=3","gravatar_id":"","url":"https://api.github.com/users/mastfish","html_url":"https://github.com/mastfish","followers_url":"https://api.github.com/users/mastfish/followers","following_url":"https://api.github.com/users/mastfish/following{/other_user}","gists_url":"https://api.github.com/users/mastfish/gists{/gist_id}","starred_url":"https://api.github.com/users/mastfish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mastfish/subscriptions","organizations_url":"https://api.github.com/users/mastfish/orgs","repos_url":"https://api.github.com/users/mastfish/repos","events_url":"https://api.github.com/users/mastfish/events{/privacy}","received_events_url":"https://api.github.com/users/mastfish/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T00:30:09Z","updated_at":"2015-05-12T00:30:09Z","body":"I agree completely with having ancestry not handle serialization; I'm suggesting accepting a block in `#arrange_serialization`(which already exists, but isn't very easy to use). This would offload serialization concerns onto users, allowing them to use whichever option they prefer.\r\n\r\nSomething like:\r\n```ruby\r\ndef arrange_serializable options={}, nodes=nil, &block\r\n      nodes = arrange(options) if nodes.nil?\r\n      nodes.map do |parent, children|\r\n      if block_provided?\r\n        yield parent, arrange_serializable(options, children, &block)\r\n     else\r\n        parent.serializable_hash.merge 'children' => arrange_serializable(options, children)\r\n     end\r\nend\r\n```"}}