{"action":"created","comment":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/comments/39811808","id":39811808,"diff_hunk":"@@ -133,6 +133,16 @@\n       end\n     end\n \n+    resources :address_book, only: [], param: :address_id do\n+      collection do\n+        get :mine\n+        post :update\n+      end\n+      member do\n+        post :remove\n+      end\n+    end","path":"api/config/routes.rb","position":12,"original_position":12,"commit_id":"b06845127e6fcb5f221d02af096af71c78a3aa88","original_commit_id":"54b324aa02c8c0ae88415df1015b2647bdb648b7","user":{"login":"gvaughn","id":10173,"avatar_url":"https://avatars.githubusercontent.com/u/10173?v=3","gravatar_id":"","url":"https://api.github.com/users/gvaughn","html_url":"https://github.com/gvaughn","followers_url":"https://api.github.com/users/gvaughn/followers","following_url":"https://api.github.com/users/gvaughn/following{/other_user}","gists_url":"https://api.github.com/users/gvaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/gvaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvaughn/subscriptions","organizations_url":"https://api.github.com/users/gvaughn/orgs","repos_url":"https://api.github.com/users/gvaughn/repos","events_url":"https://api.github.com/users/gvaughn/events{/privacy}","received_events_url":"https://api.github.com/users/gvaughn/received_events","type":"User","site_admin":false},"body":"My biggest concern is encapsulation of knowledge and enforcement of constraints. Since only one address (per user) can be default, an edit to one address may cause changes to another (making one default also changes any prior default address). If we treat it in a more traditional Rails-flavored REST-ish way then the client has to know about that and re-request the entire list. We're spreading business logic out into tiers of the app where it doesn't belong. Can we have a brainstorming session in the morning to find the best compromise?\r\n\r\nThat said, the admin side of things is a good point. However, since this is currently identify users by the auth token, that's the bigger concern.","created_at":"2015-09-17T23:38:24Z","updated_at":"2015-09-17T23:38:24Z","html_url":"https://github.com/solidusio/solidus/pull/366#discussion_r39811808","pull_request_url":"https://api.github.com/repos/solidusio/solidus/pulls/366","_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments/39811808"},"html":{"href":"https://github.com/solidusio/solidus/pull/366#discussion_r39811808"},"pull_request":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/366"}}},"pull_request":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/366","id":44986166,"html_url":"https://github.com/solidusio/solidus/pull/366","diff_url":"https://github.com/solidusio/solidus/pull/366.diff","patch_url":"https://github.com/solidusio/solidus/pull/366.patch","issue_url":"https://api.github.com/repos/solidusio/solidus/issues/366","number":366,"state":"open","locked":false,"title":"new AddressBookController","user":{"login":"gvaughn","id":10173,"avatar_url":"https://avatars.githubusercontent.com/u/10173?v=3","gravatar_id":"","url":"https://api.github.com/users/gvaughn","html_url":"https://github.com/gvaughn","followers_url":"https://api.github.com/users/gvaughn/followers","following_url":"https://api.github.com/users/gvaughn/following{/other_user}","gists_url":"https://api.github.com/users/gvaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/gvaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvaughn/subscriptions","organizations_url":"https://api.github.com/users/gvaughn/orgs","repos_url":"https://api.github.com/users/gvaughn/repos","events_url":"https://api.github.com/users/gvaughn/events{/privacy}","received_events_url":"https://api.github.com/users/gvaughn/received_events","type":"User","site_admin":false},"body":"This is the followup to my prior address book work. It:\r\n\r\nprovides endpoints suitable for a custom address book management UI\r\nadds a Spree:Config preference: automatic_default_address\r\ntest coverage\r\n\r\nHere's some more background. Sorry I didn't write this up when I originally submitted the PR.\r\n\r\nThe work goes back to making Address a readonly model and avoiding cloning the Address everywhere. Given that readonly behavior, Address is no longer a resource; it's a value object. I have tried to encapsulate the logic that manages copy-on-write semantics for Address. I strongly did not want every controller that works with every model that has an Address to deal with the logic.\r\n\r\nAt the UserAddressBook concern level there's an additional constraint that I want to encapsulate in the model layer and not require controllers to deal with -- when a UserAddress is marked as default, any other UserAddress marked as default for that user has to also change (sort order also changes). The set of addresses is the unit of encapsulation. That's the core reason that I wrote this code with the Address _BOOK_ as the conceptual resource and the reason I return the entire list. I'd welcome any high level discussion of it at this level, but that's hard to achieve in a PR format.","created_at":"2015-09-14T21:56:45Z","updated_at":"2015-09-17T23:38:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a4c3f0c5356eb74c538f66e1fc849033d2d681d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/solidusio/solidus/pulls/366/commits","review_comments_url":"https://api.github.com/repos/solidusio/solidus/pulls/366/comments","review_comment_url":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solidusio/solidus/issues/366/comments","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/b06845127e6fcb5f221d02af096af71c78a3aa88","head":{"label":"bonobos:address_book","ref":"address_book","sha":"b06845127e6fcb5f221d02af096af71c78a3aa88","user":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?v=3","gravatar_id":"","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"repo":{"id":37876553,"name":"solidus","full_name":"bonobos/solidus","owner":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?v=3","gravatar_id":"","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonobos/solidus","description":"Solidus e-commerce system","fork":true,"url":"https://api.github.com/repos/bonobos/solidus","forks_url":"https://api.github.com/repos/bonobos/solidus/forks","keys_url":"https://api.github.com/repos/bonobos/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonobos/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonobos/solidus/teams","hooks_url":"https://api.github.com/repos/bonobos/solidus/hooks","issue_events_url":"https://api.github.com/repos/bonobos/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/bonobos/solidus/events","assignees_url":"https://api.github.com/repos/bonobos/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/bonobos/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/bonobos/solidus/tags","blobs_url":"https://api.github.com/repos/bonobos/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonobos/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonobos/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonobos/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonobos/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/bonobos/solidus/languages","stargazers_url":"https://api.github.com/repos/bonobos/solidus/stargazers","contributors_url":"https://api.github.com/repos/bonobos/solidus/contributors","subscribers_url":"https://api.github.com/repos/bonobos/solidus/subscribers","subscription_url":"https://api.github.com/repos/bonobos/solidus/subscription","commits_url":"https://api.github.com/repos/bonobos/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonobos/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonobos/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonobos/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/bonobos/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/bonobos/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonobos/solidus/merges","archive_url":"https://api.github.com/repos/bonobos/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonobos/solidus/downloads","issues_url":"https://api.github.com/repos/bonobos/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/bonobos/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/bonobos/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/bonobos/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonobos/solidus/labels{/name}","releases_url":"https://api.github.com/repos/bonobos/solidus/releases{/id}","created_at":"2015-06-22T19:37:20Z","updated_at":"2015-06-22T19:37:24Z","pushed_at":"2015-09-17T23:18:44Z","git_url":"git://github.com/bonobos/solidus.git","ssh_url":"git@github.com:bonobos/solidus.git","clone_url":"https://github.com/bonobos/solidus.git","svn_url":"https://github.com/bonobos/solidus","homepage":"","size":63850,"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":"solidusio:master","ref":"master","sha":"6a1ce7fb5c6d3a8c40705cd847743c53a35257c4","user":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"repo":{"id":30985840,"name":"solidus","full_name":"solidusio/solidus","owner":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solidusio/solidus","description":"Solidus, Rails eCommerce System","fork":false,"url":"https://api.github.com/repos/solidusio/solidus","forks_url":"https://api.github.com/repos/solidusio/solidus/forks","keys_url":"https://api.github.com/repos/solidusio/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solidusio/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solidusio/solidus/teams","hooks_url":"https://api.github.com/repos/solidusio/solidus/hooks","issue_events_url":"https://api.github.com/repos/solidusio/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/solidusio/solidus/events","assignees_url":"https://api.github.com/repos/solidusio/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/solidusio/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/solidusio/solidus/tags","blobs_url":"https://api.github.com/repos/solidusio/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solidusio/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solidusio/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/solidusio/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/solidusio/solidus/languages","stargazers_url":"https://api.github.com/repos/solidusio/solidus/stargazers","contributors_url":"https://api.github.com/repos/solidusio/solidus/contributors","subscribers_url":"https://api.github.com/repos/solidusio/solidus/subscribers","subscription_url":"https://api.github.com/repos/solidusio/solidus/subscription","commits_url":"https://api.github.com/repos/solidusio/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/solidusio/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/solidusio/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/solidusio/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/solidusio/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/solidusio/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solidusio/solidus/merges","archive_url":"https://api.github.com/repos/solidusio/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solidusio/solidus/downloads","issues_url":"https://api.github.com/repos/solidusio/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/solidusio/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/solidusio/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/solidusio/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solidusio/solidus/labels{/name}","releases_url":"https://api.github.com/repos/solidusio/solidus/releases{/id}","created_at":"2015-02-18T20:41:58Z","updated_at":"2015-09-16T13:35:28Z","pushed_at":"2015-09-17T23:18:45Z","git_url":"git://github.com/solidusio/solidus.git","ssh_url":"git@github.com:solidusio/solidus.git","clone_url":"https://github.com/solidusio/solidus.git","svn_url":"https://github.com/solidusio/solidus","homepage":"http://solidus.io/","size":67033,"stargazers_count":45,"watchers_count":45,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":45,"forks":28,"open_issues":45,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/366"},"html":{"href":"https://github.com/solidusio/solidus/pull/366"},"issue":{"href":"https://api.github.com/repos/solidusio/solidus/issues/366"},"comments":{"href":"https://api.github.com/repos/solidusio/solidus/issues/366/comments"},"review_comments":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/366/comments"},"review_comment":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/366/commits"},"statuses":{"href":"https://api.github.com/repos/solidusio/solidus/statuses/b06845127e6fcb5f221d02af096af71c78a3aa88"}}}}