{"action":"created","comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/70666132","id":70666132,"diff_hunk":"@@ -0,0 +1,227 @@\n+[Back to Guides](../README.md)\n+\n+# How to migrate from `0.8` to `0.10` safely\n+\n+## Disclaimer\n+### Proceed at your own risk\n+This document attempts to outline steps to upgrade your app based on the collective experience of\n+developers who have done this already. It may not cover all edge cases and situation that may cause issues, \n+so please proceed with a certain level of caution. \n+\n+## Overview\n+This document outlines the steps needed to migrate from `0.8` to `0.10`. The method described\n+below has been created via the collective knowledge of contributions of those who have done\n+the migration successfully. The method has been tested specifically for migrating from `0.8.3`\n+to `0.10.2`.\n+\n+The high level approach is to upgrade to `0.10` and change all serializers to use \n+a backwards-compatible `VersionEightSerializer`or `VersionEightCollectionSerializer` \n+and a `VersionEightAdapter`. After a few more manual changes, you should have the same\n+functionality as you had with `AMS 0.8`. Then, you can continue to develop in your app by creating\n+new serializers that don't use these backwards compatible versions and slowly migrate\n+existing serializers to the `0.10` versions as needed.\n+\n+## Steps to migrate\n+\n+### 1. Upgrade the `active_model_serializer` gem in you `Gemfile`\n+Change to `gem 'active_model_serializers', '~> 0.10'` and run `bundle install`\n+\n+### 2. Add `VersionEightSerializer`\n+\n+#### Code\n+```ruby\n+module ActiveModel\n+  class VersionEightSerializer < Serializer\n+    include Rails.application.routes.url_helpers\n+\n+    # AMS 0.8 would delegate method calls from within the serializer to the\n+    # object.\n+    def method_missing(*args)\n+      method = args.first\n+      read_attribute_for_serialization(method)\n+    end\n+\n+    alias_method :options, :instance_options\n+\n+    # Since attributes could be read from the `object` via `method_missing`,\n+    # the `try` method did not behave as before. This patches `try` with the\n+    # original implementation plus the addition of\n+    # ` || object.respond_to?(a.first)` to check if the object responded to\n+    # the given method.\n+    def try(*a, &b)\n+      if a.empty? || respond_to?(a.first) || object.respond_to?(a.first)","path":"docs/howto/upgrade_from_0_8_to_0_10.md","position":52,"original_position":52,"commit_id":"3ecc3ed0c173b40be28226f025fa787ee9d05b73","original_commit_id":"3ecc3ed0c173b40be28226f025fa787ee9d05b73","user":{"login":"bkoltai","id":464764,"avatar_url":"https://avatars.githubusercontent.com/u/464764?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoltai","html_url":"https://github.com/bkoltai","followers_url":"https://api.github.com/users/bkoltai/followers","following_url":"https://api.github.com/users/bkoltai/following{/other_user}","gists_url":"https://api.github.com/users/bkoltai/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoltai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoltai/subscriptions","organizations_url":"https://api.github.com/users/bkoltai/orgs","repos_url":"https://api.github.com/users/bkoltai/repos","events_url":"https://api.github.com/users/bkoltai/events{/privacy}","received_events_url":"https://api.github.com/users/bkoltai/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2016-07-13T17:04:52Z","updated_at":"2016-07-13T17:04:52Z","html_url":"https://github.com/rails-api/active_model_serializers/pull/1844#discussion_r70666132","pull_request_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844","_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/70666132"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1844#discussion_r70666132"},"pull_request":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844"}}},"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844","id":77324110,"html_url":"https://github.com/rails-api/active_model_serializers/pull/1844","diff_url":"https://github.com/rails-api/active_model_serializers/pull/1844.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/1844.patch","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1844","number":1844,"state":"open","locked":false,"title":"Add documentation on upgrading from `0.8` to `0.10` safely","user":{"login":"bkoltai","id":464764,"avatar_url":"https://avatars.githubusercontent.com/u/464764?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoltai","html_url":"https://github.com/bkoltai","followers_url":"https://api.github.com/users/bkoltai/followers","following_url":"https://api.github.com/users/bkoltai/following{/other_user}","gists_url":"https://api.github.com/users/bkoltai/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoltai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoltai/subscriptions","organizations_url":"https://api.github.com/users/bkoltai/orgs","repos_url":"https://api.github.com/users/bkoltai/repos","events_url":"https://api.github.com/users/bkoltai/events{/privacy}","received_events_url":"https://api.github.com/users/bkoltai/received_events","type":"User","site_admin":false},"body":"#### Purpose\r\nProvide guidance on how to upgrade from `0.8` to `0.10` safely, based on my experience recently upgrading my `0.8.3` app to `0.10.2` successfully.\r\n\r\n#### Changes\r\nAdds `docs/howto/upgrade_from_0_8_to_0_10.md`\r\n\r\n#### Caveats\r\nThe upgrade doc may not contain all edge cases and possible issues during migration. It is purely a documentation of the process that worked for my app.\r\n\r\nIt maybe be that this is more useful as a gem or some other way with proper testing. Unfortunately, I don't think I'll have time to do this myself, but I wanted to get this out so that someone else could move forward with their migration and contribute a gem that encapsulates the code snippets I provide with proper testing. I hope this document is still useful without this.\r\n\r\n#### Related GitHub issues\r\nhttps://github.com/rails-api/active_model_serializers/issues/1694\r\nhttps://github.com/rails-api/active_model_serializers/issues/1005\r\n\r\n\r\n\r\n","created_at":"2016-07-13T16:54:42Z","updated_at":"2016-07-13T17:04:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44342596520b9fbce50b8cd94d148a5640b0dc7b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844/commits","review_comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844/comments","review_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1844/comments","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/3ecc3ed0c173b40be28226f025fa787ee9d05b73","head":{"label":"bkoltai:bk_upgrade_0_8_to_0_10_doc","ref":"bk_upgrade_0_8_to_0_10_doc","sha":"3ecc3ed0c173b40be28226f025fa787ee9d05b73","user":{"login":"bkoltai","id":464764,"avatar_url":"https://avatars.githubusercontent.com/u/464764?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoltai","html_url":"https://github.com/bkoltai","followers_url":"https://api.github.com/users/bkoltai/followers","following_url":"https://api.github.com/users/bkoltai/following{/other_user}","gists_url":"https://api.github.com/users/bkoltai/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoltai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoltai/subscriptions","organizations_url":"https://api.github.com/users/bkoltai/orgs","repos_url":"https://api.github.com/users/bkoltai/repos","events_url":"https://api.github.com/users/bkoltai/events{/privacy}","received_events_url":"https://api.github.com/users/bkoltai/received_events","type":"User","site_admin":false},"repo":{"id":62934612,"name":"active_model_serializers","full_name":"bkoltai/active_model_serializers","owner":{"login":"bkoltai","id":464764,"avatar_url":"https://avatars.githubusercontent.com/u/464764?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoltai","html_url":"https://github.com/bkoltai","followers_url":"https://api.github.com/users/bkoltai/followers","following_url":"https://api.github.com/users/bkoltai/following{/other_user}","gists_url":"https://api.github.com/users/bkoltai/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoltai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoltai/subscriptions","organizations_url":"https://api.github.com/users/bkoltai/orgs","repos_url":"https://api.github.com/users/bkoltai/repos","events_url":"https://api.github.com/users/bkoltai/events{/privacy}","received_events_url":"https://api.github.com/users/bkoltai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bkoltai/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":true,"url":"https://api.github.com/repos/bkoltai/active_model_serializers","forks_url":"https://api.github.com/repos/bkoltai/active_model_serializers/forks","keys_url":"https://api.github.com/repos/bkoltai/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bkoltai/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bkoltai/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/bkoltai/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/bkoltai/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/bkoltai/active_model_serializers/events","assignees_url":"https://api.github.com/repos/bkoltai/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/bkoltai/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/bkoltai/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/bkoltai/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bkoltai/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bkoltai/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/bkoltai/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bkoltai/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/bkoltai/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/bkoltai/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/bkoltai/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/bkoltai/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/bkoltai/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/bkoltai/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/bkoltai/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/bkoltai/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/bkoltai/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/bkoltai/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/bkoltai/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bkoltai/active_model_serializers/merges","archive_url":"https://api.github.com/repos/bkoltai/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bkoltai/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/bkoltai/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/bkoltai/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/bkoltai/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/bkoltai/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bkoltai/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/bkoltai/active_model_serializers/releases{/id}","deployments_url":"https://api.github.com/repos/bkoltai/active_model_serializers/deployments","created_at":"2016-07-09T05:51:13Z","updated_at":"2016-07-09T05:51:14Z","pushed_at":"2016-07-13T16:49:26Z","git_url":"git://github.com/bkoltai/active_model_serializers.git","ssh_url":"git@github.com:bkoltai/active_model_serializers.git","clone_url":"https://github.com/bkoltai/active_model_serializers.git","svn_url":"https://github.com/bkoltai/active_model_serializers","homepage":"","size":5341,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails-api:master","ref":"master","sha":"9a206a1f5d097436e398b29c4477d202af65864a","user":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"repo":{"id":2889230,"name":"active_model_serializers","full_name":"rails-api/active_model_serializers","owner":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails-api/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":false,"url":"https://api.github.com/repos/rails-api/active_model_serializers","forks_url":"https://api.github.com/repos/rails-api/active_model_serializers/forks","keys_url":"https://api.github.com/repos/rails-api/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails-api/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails-api/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/rails-api/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/events","assignees_url":"https://api.github.com/repos/rails-api/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/rails-api/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/rails-api/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/rails-api/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/rails-api/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails-api/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/rails-api/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails-api/active_model_serializers/merges","archive_url":"https://api.github.com/repos/rails-api/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails-api/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/rails-api/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/rails-api/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/rails-api/active_model_serializers/releases{/id}","deployments_url":"https://api.github.com/repos/rails-api/active_model_serializers/deployments","created_at":"2011-12-01T06:39:26Z","updated_at":"2016-07-13T03:18:07Z","pushed_at":"2016-07-13T16:54:43Z","git_url":"git://github.com/rails-api/active_model_serializers.git","ssh_url":"git@github.com:rails-api/active_model_serializers.git","clone_url":"https://github.com/rails-api/active_model_serializers.git","svn_url":"https://github.com/rails-api/active_model_serializers","homepage":"","size":5349,"stargazers_count":3634,"watchers_count":3634,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":952,"mirror_url":null,"open_issues_count":108,"forks":952,"open_issues":108,"watchers":3634,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1844"},"issue":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1844"},"comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1844/comments"},"review_comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844/comments"},"review_comment":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1844/commits"},"statuses":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/3ecc3ed0c173b40be28226f025fa787ee9d05b73"}}}}
{"actor":{"display_login":"bkoltai"}}