{"action":"created","comment":{"url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/comments/84275190","pull_request_review_id":5062057,"id":84275190,"diff_hunk":"@@ -36,10 +36,25 @@ def destroy\n     current_user.author_of?(@question) ? respond_with(@question.destroy) : redirect_to(@question)\n   end\n \n+  def subscribe\n+    authorize! :subscribe, @question\n+    @subscription = current_user.subscriptions.build\n+    @subscription.question = @question\n+    @subscription.save\n+  end\n+\n+  def unsubscribe\n+    authorize! :unsubscribe, @question\n+    @subscription = Subscription.where('user_id = ? AND question_id = ?',\n+                                       current_user.id, @question.id).take\n+    @subscription.destroy\n+  end\n+\n   private\n \n   def find_question\n-    @question = Question.find(params[:id])\n+    @question = Question.find(params[:id]) if params[:id]\n+    @question = Question.find(params[:question_id]) if params[:question_id]","path":"app/controllers/questions_controller.rb","position":32,"original_position":32,"commit_id":"8b681102594ce6c675fdfa54e16a3174865ed1a1","original_commit_id":"8b681102594ce6c675fdfa54e16a3174865ed1a1","user":{"login":"AleksandrKudashkin","id":11471420,"avatar_url":"https://avatars.githubusercontent.com/u/11471420?v=3","gravatar_id":"","url":"https://api.github.com/users/AleksandrKudashkin","html_url":"https://github.com/AleksandrKudashkin","followers_url":"https://api.github.com/users/AleksandrKudashkin/followers","following_url":"https://api.github.com/users/AleksandrKudashkin/following{/other_user}","gists_url":"https://api.github.com/users/AleksandrKudashkin/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksandrKudashkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksandrKudashkin/subscriptions","organizations_url":"https://api.github.com/users/AleksandrKudashkin/orgs","repos_url":"https://api.github.com/users/AleksandrKudashkin/repos","events_url":"https://api.github.com/users/AleksandrKudashkin/events{/privacy}","received_events_url":"https://api.github.com/users/AleksandrKudashkin/received_events","type":"User","site_admin":false},"body":"Ссылки на Subscribe/Unsubscribe используют вложенные роуты, то есть при создании/удалении подписки используется question_id. Это не комильфо?","created_at":"2016-10-20T12:54:22Z","updated_at":"2016-10-20T12:54:22Z","html_url":"https://github.com/AleksandrKudashkin/qna/pull/15#discussion_r84275190","pull_request_url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/comments/84275190"},"html":{"href":"https://github.com/AleksandrKudashkin/qna/pull/15#discussion_r84275190"},"pull_request":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15","id":90128359,"html_url":"https://github.com/AleksandrKudashkin/qna/pull/15","diff_url":"https://github.com/AleksandrKudashkin/qna/pull/15.diff","patch_url":"https://github.com/AleksandrKudashkin/qna/pull/15.patch","issue_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/15","number":15,"state":"open","locked":false,"title":"[#17] Add AJ notifications NewAnswer, DailyDigest","user":{"login":"AleksandrKudashkin","id":11471420,"avatar_url":"https://avatars.githubusercontent.com/u/11471420?v=3","gravatar_id":"","url":"https://api.github.com/users/AleksandrKudashkin","html_url":"https://github.com/AleksandrKudashkin","followers_url":"https://api.github.com/users/AleksandrKudashkin/followers","following_url":"https://api.github.com/users/AleksandrKudashkin/following{/other_user}","gists_url":"https://api.github.com/users/AleksandrKudashkin/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksandrKudashkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksandrKudashkin/subscriptions","organizations_url":"https://api.github.com/users/AleksandrKudashkin/orgs","repos_url":"https://api.github.com/users/AleksandrKudashkin/repos","events_url":"https://api.github.com/users/AleksandrKudashkin/events{/privacy}","received_events_url":"https://api.github.com/users/AleksandrKudashkin/received_events","type":"User","site_admin":false},"body":"* Add digest query for Questions\r\n* Send email when new answer\r\n* Add sending digest\r\n* Add sidekiq\r\n* Add sidekiq web\r\n* Switch notification to sidekiq\r\n* Add Subscriptions model\r\n* Add subscription to questions\r\n* Add unsubscribe test\r\n* Add test for subscribed_to?\r\n* Modify test for notifying subscribers\r\n* Add test for autosubscribing author of question\r\n* Modify test for a new answer job\r\n* Fix delivering\r\n* Fix DailyDigestJob spec\r\n* Fix ability spec\r\n* Add controller test and whenever","created_at":"2016-10-20T03:39:03Z","updated_at":"2016-10-20T12:54:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e0792fb401132a4ef32a6aa58a0cfb32713ac66","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15/commits","review_comments_url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15/comments","review_comment_url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/15/comments","statuses_url":"https://api.github.com/repos/AleksandrKudashkin/qna/statuses/8b681102594ce6c675fdfa54e16a3174865ed1a1","head":{"label":"AleksandrKudashkin:Lesson17","ref":"Lesson17","sha":"8b681102594ce6c675fdfa54e16a3174865ed1a1","user":{"login":"AleksandrKudashkin","id":11471420,"avatar_url":"https://avatars.githubusercontent.com/u/11471420?v=3","gravatar_id":"","url":"https://api.github.com/users/AleksandrKudashkin","html_url":"https://github.com/AleksandrKudashkin","followers_url":"https://api.github.com/users/AleksandrKudashkin/followers","following_url":"https://api.github.com/users/AleksandrKudashkin/following{/other_user}","gists_url":"https://api.github.com/users/AleksandrKudashkin/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksandrKudashkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksandrKudashkin/subscriptions","organizations_url":"https://api.github.com/users/AleksandrKudashkin/orgs","repos_url":"https://api.github.com/users/AleksandrKudashkin/repos","events_url":"https://api.github.com/users/AleksandrKudashkin/events{/privacy}","received_events_url":"https://api.github.com/users/AleksandrKudashkin/received_events","type":"User","site_admin":false},"repo":{"id":37356411,"name":"qna","full_name":"AleksandrKudashkin/qna","owner":{"login":"AleksandrKudashkin","id":11471420,"avatar_url":"https://avatars.githubusercontent.com/u/11471420?v=3","gravatar_id":"","url":"https://api.github.com/users/AleksandrKudashkin","html_url":"https://github.com/AleksandrKudashkin","followers_url":"https://api.github.com/users/AleksandrKudashkin/followers","following_url":"https://api.github.com/users/AleksandrKudashkin/following{/other_user}","gists_url":"https://api.github.com/users/AleksandrKudashkin/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksandrKudashkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksandrKudashkin/subscriptions","organizations_url":"https://api.github.com/users/AleksandrKudashkin/orgs","repos_url":"https://api.github.com/users/AleksandrKudashkin/repos","events_url":"https://api.github.com/users/AleksandrKudashkin/events{/privacy}","received_events_url":"https://api.github.com/users/AleksandrKudashkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AleksandrKudashkin/qna","description":"A class project for course \"Professional Development with RoR\" at Thinknetica","fork":false,"url":"https://api.github.com/repos/AleksandrKudashkin/qna","forks_url":"https://api.github.com/repos/AleksandrKudashkin/qna/forks","keys_url":"https://api.github.com/repos/AleksandrKudashkin/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AleksandrKudashkin/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AleksandrKudashkin/qna/teams","hooks_url":"https://api.github.com/repos/AleksandrKudashkin/qna/hooks","issue_events_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/events{/number}","events_url":"https://api.github.com/repos/AleksandrKudashkin/qna/events","assignees_url":"https://api.github.com/repos/AleksandrKudashkin/qna/assignees{/user}","branches_url":"https://api.github.com/repos/AleksandrKudashkin/qna/branches{/branch}","tags_url":"https://api.github.com/repos/AleksandrKudashkin/qna/tags","blobs_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AleksandrKudashkin/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/AleksandrKudashkin/qna/languages","stargazers_url":"https://api.github.com/repos/AleksandrKudashkin/qna/stargazers","contributors_url":"https://api.github.com/repos/AleksandrKudashkin/qna/contributors","subscribers_url":"https://api.github.com/repos/AleksandrKudashkin/qna/subscribers","subscription_url":"https://api.github.com/repos/AleksandrKudashkin/qna/subscription","commits_url":"https://api.github.com/repos/AleksandrKudashkin/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/AleksandrKudashkin/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/AleksandrKudashkin/qna/contents/{+path}","compare_url":"https://api.github.com/repos/AleksandrKudashkin/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AleksandrKudashkin/qna/merges","archive_url":"https://api.github.com/repos/AleksandrKudashkin/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AleksandrKudashkin/qna/downloads","issues_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues{/number}","pulls_url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/AleksandrKudashkin/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/AleksandrKudashkin/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AleksandrKudashkin/qna/labels{/name}","releases_url":"https://api.github.com/repos/AleksandrKudashkin/qna/releases{/id}","deployments_url":"https://api.github.com/repos/AleksandrKudashkin/qna/deployments","created_at":"2015-06-13T03:38:05Z","updated_at":"2016-09-07T15:46:34Z","pushed_at":"2016-10-20T03:39:03Z","git_url":"git://github.com/AleksandrKudashkin/qna.git","ssh_url":"git@github.com:AleksandrKudashkin/qna.git","clone_url":"https://github.com/AleksandrKudashkin/qna.git","svn_url":"https://github.com/AleksandrKudashkin/qna","homepage":"","size":237,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"AleksandrKudashkin:master","ref":"master","sha":"e73c4620e52fa9b04107cc7b14928c65dbc2c186","user":{"login":"AleksandrKudashkin","id":11471420,"avatar_url":"https://avatars.githubusercontent.com/u/11471420?v=3","gravatar_id":"","url":"https://api.github.com/users/AleksandrKudashkin","html_url":"https://github.com/AleksandrKudashkin","followers_url":"https://api.github.com/users/AleksandrKudashkin/followers","following_url":"https://api.github.com/users/AleksandrKudashkin/following{/other_user}","gists_url":"https://api.github.com/users/AleksandrKudashkin/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksandrKudashkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksandrKudashkin/subscriptions","organizations_url":"https://api.github.com/users/AleksandrKudashkin/orgs","repos_url":"https://api.github.com/users/AleksandrKudashkin/repos","events_url":"https://api.github.com/users/AleksandrKudashkin/events{/privacy}","received_events_url":"https://api.github.com/users/AleksandrKudashkin/received_events","type":"User","site_admin":false},"repo":{"id":37356411,"name":"qna","full_name":"AleksandrKudashkin/qna","owner":{"login":"AleksandrKudashkin","id":11471420,"avatar_url":"https://avatars.githubusercontent.com/u/11471420?v=3","gravatar_id":"","url":"https://api.github.com/users/AleksandrKudashkin","html_url":"https://github.com/AleksandrKudashkin","followers_url":"https://api.github.com/users/AleksandrKudashkin/followers","following_url":"https://api.github.com/users/AleksandrKudashkin/following{/other_user}","gists_url":"https://api.github.com/users/AleksandrKudashkin/gists{/gist_id}","starred_url":"https://api.github.com/users/AleksandrKudashkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AleksandrKudashkin/subscriptions","organizations_url":"https://api.github.com/users/AleksandrKudashkin/orgs","repos_url":"https://api.github.com/users/AleksandrKudashkin/repos","events_url":"https://api.github.com/users/AleksandrKudashkin/events{/privacy}","received_events_url":"https://api.github.com/users/AleksandrKudashkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AleksandrKudashkin/qna","description":"A class project for course \"Professional Development with RoR\" at Thinknetica","fork":false,"url":"https://api.github.com/repos/AleksandrKudashkin/qna","forks_url":"https://api.github.com/repos/AleksandrKudashkin/qna/forks","keys_url":"https://api.github.com/repos/AleksandrKudashkin/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AleksandrKudashkin/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AleksandrKudashkin/qna/teams","hooks_url":"https://api.github.com/repos/AleksandrKudashkin/qna/hooks","issue_events_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/events{/number}","events_url":"https://api.github.com/repos/AleksandrKudashkin/qna/events","assignees_url":"https://api.github.com/repos/AleksandrKudashkin/qna/assignees{/user}","branches_url":"https://api.github.com/repos/AleksandrKudashkin/qna/branches{/branch}","tags_url":"https://api.github.com/repos/AleksandrKudashkin/qna/tags","blobs_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AleksandrKudashkin/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/AleksandrKudashkin/qna/languages","stargazers_url":"https://api.github.com/repos/AleksandrKudashkin/qna/stargazers","contributors_url":"https://api.github.com/repos/AleksandrKudashkin/qna/contributors","subscribers_url":"https://api.github.com/repos/AleksandrKudashkin/qna/subscribers","subscription_url":"https://api.github.com/repos/AleksandrKudashkin/qna/subscription","commits_url":"https://api.github.com/repos/AleksandrKudashkin/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/AleksandrKudashkin/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/AleksandrKudashkin/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/AleksandrKudashkin/qna/contents/{+path}","compare_url":"https://api.github.com/repos/AleksandrKudashkin/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AleksandrKudashkin/qna/merges","archive_url":"https://api.github.com/repos/AleksandrKudashkin/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AleksandrKudashkin/qna/downloads","issues_url":"https://api.github.com/repos/AleksandrKudashkin/qna/issues{/number}","pulls_url":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/AleksandrKudashkin/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/AleksandrKudashkin/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AleksandrKudashkin/qna/labels{/name}","releases_url":"https://api.github.com/repos/AleksandrKudashkin/qna/releases{/id}","deployments_url":"https://api.github.com/repos/AleksandrKudashkin/qna/deployments","created_at":"2015-06-13T03:38:05Z","updated_at":"2016-09-07T15:46:34Z","pushed_at":"2016-10-20T03:39:03Z","git_url":"git://github.com/AleksandrKudashkin/qna.git","ssh_url":"git@github.com:AleksandrKudashkin/qna.git","clone_url":"https://github.com/AleksandrKudashkin/qna.git","svn_url":"https://github.com/AleksandrKudashkin/qna","homepage":"","size":237,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15"},"html":{"href":"https://github.com/AleksandrKudashkin/qna/pull/15"},"issue":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/15"},"comments":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/AleksandrKudashkin/qna/statuses/8b681102594ce6c675fdfa54e16a3174865ed1a1"}}}}
{"actor":{"display_login":"AleksandrKudashkin"}}