{"action":"created","comment":{"url":"https://api.github.com/repos/CraftAcademy/homechef/pulls/comments/98333355","pull_request_review_id":18975653,"id":98333355,"diff_hunk":"@@ -1,13 +1,24 @@\n class OrdersController < ApplicationController\n+  before_action :authenticate_user!\n+\n   def add_to_order\n-    if Order.last\n-      order = Order.last\n-    else\n-      order = Order.create\n+\t  if session[:order_id] == nil || Order.find(session[:order_id]).finalized == true","path":"app/controllers/orders_controller.rb","position":null,"original_position":9,"commit_id":"55760a3a1923a4d777f36e44659489480b58339d","original_commit_id":"f661e1531b99a40ff02fca3b71250a1d5d0beb4c","user":{"login":"tochman","id":5248170,"avatar_url":"https://avatars.githubusercontent.com/u/5248170?v=3","gravatar_id":"","url":"https://api.github.com/users/tochman","html_url":"https://github.com/tochman","followers_url":"https://api.github.com/users/tochman/followers","following_url":"https://api.github.com/users/tochman/following{/other_user}","gists_url":"https://api.github.com/users/tochman/gists{/gist_id}","starred_url":"https://api.github.com/users/tochman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tochman/subscriptions","organizations_url":"https://api.github.com/users/tochman/orgs","repos_url":"https://api.github.com/users/tochman/repos","events_url":"https://api.github.com/users/tochman/events{/privacy}","received_events_url":"https://api.github.com/users/tochman/received_events","type":"User","site_admin":false},"body":"I would do something  simple like \r\n```\r\nsession.delete[:order_id] \r\n```\r\nonce the order is processed....","created_at":"2017-01-28T15:51:11Z","updated_at":"2017-01-28T15:51:11Z","html_url":"https://github.com/CraftAcademy/homechef/pull/13#discussion_r98333355","pull_request_url":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/CraftAcademy/homechef/pulls/comments/98333355"},"html":{"href":"https://github.com/CraftAcademy/homechef/pull/13#discussion_r98333355"},"pull_request":{"href":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13","id":103103342,"html_url":"https://github.com/CraftAcademy/homechef/pull/13","diff_url":"https://github.com/CraftAcademy/homechef/pull/13.diff","patch_url":"https://github.com/CraftAcademy/homechef/pull/13.patch","issue_url":"https://api.github.com/repos/CraftAcademy/homechef/issues/13","number":13,"state":"open","locked":false,"title":"Chore: Marking orders as purchased after payment","user":{"login":"Philippoes","id":22058587,"avatar_url":"https://avatars.githubusercontent.com/u/22058587?v=3","gravatar_id":"","url":"https://api.github.com/users/Philippoes","html_url":"https://github.com/Philippoes","followers_url":"https://api.github.com/users/Philippoes/followers","following_url":"https://api.github.com/users/Philippoes/following{/other_user}","gists_url":"https://api.github.com/users/Philippoes/gists{/gist_id}","starred_url":"https://api.github.com/users/Philippoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Philippoes/subscriptions","organizations_url":"https://api.github.com/users/Philippoes/orgs","repos_url":"https://api.github.com/users/Philippoes/repos","events_url":"https://api.github.com/users/Philippoes/events{/privacy}","received_events_url":"https://api.github.com/users/Philippoes/received_events","type":"User","site_admin":false},"body":"## Pivotal Tracker story \r\n[https://www.pivotaltracker.com/story/show/137650777](url)\r\n\r\n## Changes proposed in this pull request:\r\n\r\nIntroduces a new attribute to the Order model. Finalized: which is a boolean and is automatically set to false when the order is created (When a user adds a dish). And is set to true when the payment is done. And when a user adds a new dish to order after purchase a new order will be created and the old will stay in the database.\r\n\r\nThis PR also introduces Sessions. And is using sessions to access the current order throughout the system.\r\n\r\n## What I have learned working on this feature:\r\n\r\nThis has been good practice for us, since we now understand very clearly how we will display all the bought dishes and orders in future features. Also how to incorporate session in to the logic.\r\n\r\n## Ready for review!","created_at":"2017-01-25T11:45:36Z","updated_at":"2017-01-28T15:51:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff1691ec82a1ed23364eb9435a94a6c62864b4a5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13/commits","review_comments_url":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13/comments","review_comment_url":"https://api.github.com/repos/CraftAcademy/homechef/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CraftAcademy/homechef/issues/13/comments","statuses_url":"https://api.github.com/repos/CraftAcademy/homechef/statuses/55760a3a1923a4d777f36e44659489480b58339d","head":{"label":"Philippoes:order_reset_purchase","ref":"order_reset_purchase","sha":"55760a3a1923a4d777f36e44659489480b58339d","user":{"login":"Philippoes","id":22058587,"avatar_url":"https://avatars.githubusercontent.com/u/22058587?v=3","gravatar_id":"","url":"https://api.github.com/users/Philippoes","html_url":"https://github.com/Philippoes","followers_url":"https://api.github.com/users/Philippoes/followers","following_url":"https://api.github.com/users/Philippoes/following{/other_user}","gists_url":"https://api.github.com/users/Philippoes/gists{/gist_id}","starred_url":"https://api.github.com/users/Philippoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Philippoes/subscriptions","organizations_url":"https://api.github.com/users/Philippoes/orgs","repos_url":"https://api.github.com/users/Philippoes/repos","events_url":"https://api.github.com/users/Philippoes/events{/privacy}","received_events_url":"https://api.github.com/users/Philippoes/received_events","type":"User","site_admin":false},"repo":{"id":78536604,"name":"homechef","full_name":"Philippoes/homechef","owner":{"login":"Philippoes","id":22058587,"avatar_url":"https://avatars.githubusercontent.com/u/22058587?v=3","gravatar_id":"","url":"https://api.github.com/users/Philippoes","html_url":"https://github.com/Philippoes","followers_url":"https://api.github.com/users/Philippoes/followers","following_url":"https://api.github.com/users/Philippoes/following{/other_user}","gists_url":"https://api.github.com/users/Philippoes/gists{/gist_id}","starred_url":"https://api.github.com/users/Philippoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Philippoes/subscriptions","organizations_url":"https://api.github.com/users/Philippoes/orgs","repos_url":"https://api.github.com/users/Philippoes/repos","events_url":"https://api.github.com/users/Philippoes/events{/privacy}","received_events_url":"https://api.github.com/users/Philippoes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Philippoes/homechef","description":"Midcourse Project - November 2016 Cohort","fork":true,"url":"https://api.github.com/repos/Philippoes/homechef","forks_url":"https://api.github.com/repos/Philippoes/homechef/forks","keys_url":"https://api.github.com/repos/Philippoes/homechef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Philippoes/homechef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Philippoes/homechef/teams","hooks_url":"https://api.github.com/repos/Philippoes/homechef/hooks","issue_events_url":"https://api.github.com/repos/Philippoes/homechef/issues/events{/number}","events_url":"https://api.github.com/repos/Philippoes/homechef/events","assignees_url":"https://api.github.com/repos/Philippoes/homechef/assignees{/user}","branches_url":"https://api.github.com/repos/Philippoes/homechef/branches{/branch}","tags_url":"https://api.github.com/repos/Philippoes/homechef/tags","blobs_url":"https://api.github.com/repos/Philippoes/homechef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Philippoes/homechef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Philippoes/homechef/git/refs{/sha}","trees_url":"https://api.github.com/repos/Philippoes/homechef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Philippoes/homechef/statuses/{sha}","languages_url":"https://api.github.com/repos/Philippoes/homechef/languages","stargazers_url":"https://api.github.com/repos/Philippoes/homechef/stargazers","contributors_url":"https://api.github.com/repos/Philippoes/homechef/contributors","subscribers_url":"https://api.github.com/repos/Philippoes/homechef/subscribers","subscription_url":"https://api.github.com/repos/Philippoes/homechef/subscription","commits_url":"https://api.github.com/repos/Philippoes/homechef/commits{/sha}","git_commits_url":"https://api.github.com/repos/Philippoes/homechef/git/commits{/sha}","comments_url":"https://api.github.com/repos/Philippoes/homechef/comments{/number}","issue_comment_url":"https://api.github.com/repos/Philippoes/homechef/issues/comments{/number}","contents_url":"https://api.github.com/repos/Philippoes/homechef/contents/{+path}","compare_url":"https://api.github.com/repos/Philippoes/homechef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Philippoes/homechef/merges","archive_url":"https://api.github.com/repos/Philippoes/homechef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Philippoes/homechef/downloads","issues_url":"https://api.github.com/repos/Philippoes/homechef/issues{/number}","pulls_url":"https://api.github.com/repos/Philippoes/homechef/pulls{/number}","milestones_url":"https://api.github.com/repos/Philippoes/homechef/milestones{/number}","notifications_url":"https://api.github.com/repos/Philippoes/homechef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Philippoes/homechef/labels{/name}","releases_url":"https://api.github.com/repos/Philippoes/homechef/releases{/id}","deployments_url":"https://api.github.com/repos/Philippoes/homechef/deployments","created_at":"2017-01-10T13:36:13Z","updated_at":"2017-01-10T13:36:14Z","pushed_at":"2017-01-28T15:43:25Z","git_url":"git://github.com/Philippoes/homechef.git","ssh_url":"git@github.com:Philippoes/homechef.git","clone_url":"https://github.com/Philippoes/homechef.git","svn_url":"https://github.com/Philippoes/homechef","homepage":null,"size":225,"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":"develop"}},"base":{"label":"CraftAcademy:develop","ref":"develop","sha":"e2fb05fb43d8455d77b66b860199158f5ff7ab08","user":{"login":"CraftAcademy","id":12081851,"avatar_url":"https://avatars.githubusercontent.com/u/12081851?v=3","gravatar_id":"","url":"https://api.github.com/users/CraftAcademy","html_url":"https://github.com/CraftAcademy","followers_url":"https://api.github.com/users/CraftAcademy/followers","following_url":"https://api.github.com/users/CraftAcademy/following{/other_user}","gists_url":"https://api.github.com/users/CraftAcademy/gists{/gist_id}","starred_url":"https://api.github.com/users/CraftAcademy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CraftAcademy/subscriptions","organizations_url":"https://api.github.com/users/CraftAcademy/orgs","repos_url":"https://api.github.com/users/CraftAcademy/repos","events_url":"https://api.github.com/users/CraftAcademy/events{/privacy}","received_events_url":"https://api.github.com/users/CraftAcademy/received_events","type":"Organization","site_admin":false},"repo":{"id":78448870,"name":"homechef","full_name":"CraftAcademy/homechef","owner":{"login":"CraftAcademy","id":12081851,"avatar_url":"https://avatars.githubusercontent.com/u/12081851?v=3","gravatar_id":"","url":"https://api.github.com/users/CraftAcademy","html_url":"https://github.com/CraftAcademy","followers_url":"https://api.github.com/users/CraftAcademy/followers","following_url":"https://api.github.com/users/CraftAcademy/following{/other_user}","gists_url":"https://api.github.com/users/CraftAcademy/gists{/gist_id}","starred_url":"https://api.github.com/users/CraftAcademy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CraftAcademy/subscriptions","organizations_url":"https://api.github.com/users/CraftAcademy/orgs","repos_url":"https://api.github.com/users/CraftAcademy/repos","events_url":"https://api.github.com/users/CraftAcademy/events{/privacy}","received_events_url":"https://api.github.com/users/CraftAcademy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CraftAcademy/homechef","description":"Midcourse Project - November 2016 Cohort","fork":false,"url":"https://api.github.com/repos/CraftAcademy/homechef","forks_url":"https://api.github.com/repos/CraftAcademy/homechef/forks","keys_url":"https://api.github.com/repos/CraftAcademy/homechef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CraftAcademy/homechef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CraftAcademy/homechef/teams","hooks_url":"https://api.github.com/repos/CraftAcademy/homechef/hooks","issue_events_url":"https://api.github.com/repos/CraftAcademy/homechef/issues/events{/number}","events_url":"https://api.github.com/repos/CraftAcademy/homechef/events","assignees_url":"https://api.github.com/repos/CraftAcademy/homechef/assignees{/user}","branches_url":"https://api.github.com/repos/CraftAcademy/homechef/branches{/branch}","tags_url":"https://api.github.com/repos/CraftAcademy/homechef/tags","blobs_url":"https://api.github.com/repos/CraftAcademy/homechef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CraftAcademy/homechef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CraftAcademy/homechef/git/refs{/sha}","trees_url":"https://api.github.com/repos/CraftAcademy/homechef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CraftAcademy/homechef/statuses/{sha}","languages_url":"https://api.github.com/repos/CraftAcademy/homechef/languages","stargazers_url":"https://api.github.com/repos/CraftAcademy/homechef/stargazers","contributors_url":"https://api.github.com/repos/CraftAcademy/homechef/contributors","subscribers_url":"https://api.github.com/repos/CraftAcademy/homechef/subscribers","subscription_url":"https://api.github.com/repos/CraftAcademy/homechef/subscription","commits_url":"https://api.github.com/repos/CraftAcademy/homechef/commits{/sha}","git_commits_url":"https://api.github.com/repos/CraftAcademy/homechef/git/commits{/sha}","comments_url":"https://api.github.com/repos/CraftAcademy/homechef/comments{/number}","issue_comment_url":"https://api.github.com/repos/CraftAcademy/homechef/issues/comments{/number}","contents_url":"https://api.github.com/repos/CraftAcademy/homechef/contents/{+path}","compare_url":"https://api.github.com/repos/CraftAcademy/homechef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CraftAcademy/homechef/merges","archive_url":"https://api.github.com/repos/CraftAcademy/homechef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CraftAcademy/homechef/downloads","issues_url":"https://api.github.com/repos/CraftAcademy/homechef/issues{/number}","pulls_url":"https://api.github.com/repos/CraftAcademy/homechef/pulls{/number}","milestones_url":"https://api.github.com/repos/CraftAcademy/homechef/milestones{/number}","notifications_url":"https://api.github.com/repos/CraftAcademy/homechef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CraftAcademy/homechef/labels{/name}","releases_url":"https://api.github.com/repos/CraftAcademy/homechef/releases{/id}","deployments_url":"https://api.github.com/repos/CraftAcademy/homechef/deployments","created_at":"2017-01-09T16:51:51Z","updated_at":"2017-01-10T11:59:40Z","pushed_at":"2017-01-28T15:43:26Z","git_url":"git://github.com/CraftAcademy/homechef.git","ssh_url":"git@github.com:CraftAcademy/homechef.git","clone_url":"https://github.com/CraftAcademy/homechef.git","svn_url":"https://github.com/CraftAcademy/homechef","homepage":null,"size":122,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13"},"html":{"href":"https://github.com/CraftAcademy/homechef/pull/13"},"issue":{"href":"https://api.github.com/repos/CraftAcademy/homechef/issues/13"},"comments":{"href":"https://api.github.com/repos/CraftAcademy/homechef/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/CraftAcademy/homechef/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CraftAcademy/homechef/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/CraftAcademy/homechef/statuses/55760a3a1923a4d777f36e44659489480b58339d"}}}}
{"actor":{"display_login":"tochman"}}