{"action":"created","comment":{"url":"https://api.github.com/repos/boutsko/qna/pulls/comments/29423760","id":29423760,"diff_hunk":"@@ -0,0 +1,45 @@\n+module Voted\n+  extend ActiveSupport::Concern\n+  \n+  included do\n+    before_action :load_votable_resource, only: [:like, :dislike, :withdraw_vote]","path":"app/controllers/concerns/voted.rb","position":5,"original_position":5,"commit_id":"9caec4ca8dbc7176796ca3f57ed78f40f139527d","original_commit_id":"9caec4ca8dbc7176796ca3f57ed78f40f139527d","user":{"login":"vkurennov","id":968537,"avatar_url":"https://avatars.githubusercontent.com/u/968537?v=3","gravatar_id":"","url":"https://api.github.com/users/vkurennov","html_url":"https://github.com/vkurennov","followers_url":"https://api.github.com/users/vkurennov/followers","following_url":"https://api.github.com/users/vkurennov/following{/other_user}","gists_url":"https://api.github.com/users/vkurennov/gists{/gist_id}","starred_url":"https://api.github.com/users/vkurennov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkurennov/subscriptions","organizations_url":"https://api.github.com/users/vkurennov/orgs","repos_url":"https://api.github.com/users/vkurennov/repos","events_url":"https://api.github.com/users/vkurennov/events{/privacy}","received_events_url":"https://api.github.com/users/vkurennov/received_events","type":"User","site_admin":false},"body":"А зачем загружать объект, если он уже загружен? Используя принцип convention over configuration можно найти уже загруженную переменную по имени контроллера. Поможет нам в этом метод instance_variable_get, возвращающий инстанс-переменную по названию. Тогда метод можно переписать так: `@votable = instance_variable_get(\"@#{controller_name.singularize}\")`","created_at":"2015-04-30T12:17:54Z","updated_at":"2015-04-30T12:17:54Z","html_url":"https://github.com/boutsko/qna/pull/8#discussion_r29423760","pull_request_url":"https://api.github.com/repos/boutsko/qna/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/boutsko/qna/pulls/comments/29423760"},"html":{"href":"https://github.com/boutsko/qna/pull/8#discussion_r29423760"},"pull_request":{"href":"https://api.github.com/repos/boutsko/qna/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/boutsko/qna/pulls/8","id":34258892,"html_url":"https://github.com/boutsko/qna/pull/8","diff_url":"https://github.com/boutsko/qna/pull/8.diff","patch_url":"https://github.com/boutsko/qna/pull/8.patch","issue_url":"https://api.github.com/repos/boutsko/qna/issues/8","number":8,"state":"open","locked":false,"title":"Lesson9","user":{"login":"boutsko","id":11396261,"avatar_url":"https://avatars.githubusercontent.com/u/11396261?v=3","gravatar_id":"","url":"https://api.github.com/users/boutsko","html_url":"https://github.com/boutsko","followers_url":"https://api.github.com/users/boutsko/followers","following_url":"https://api.github.com/users/boutsko/following{/other_user}","gists_url":"https://api.github.com/users/boutsko/gists{/gist_id}","starred_url":"https://api.github.com/users/boutsko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boutsko/subscriptions","organizations_url":"https://api.github.com/users/boutsko/orgs","repos_url":"https://api.github.com/users/boutsko/repos","events_url":"https://api.github.com/users/boutsko/events{/privacy}","received_events_url":"https://api.github.com/users/boutsko/received_events","type":"User","site_admin":false},"body":"Урок 9, concerns, jbuilder, votes через polymorphic associations.","created_at":"2015-04-28T11:55:04Z","updated_at":"2015-04-30T12:17:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00b04d9d168a3ecd58cc800b58749b2628bcc628","assignee":{"login":"vkurennov","id":968537,"avatar_url":"https://avatars.githubusercontent.com/u/968537?v=3","gravatar_id":"","url":"https://api.github.com/users/vkurennov","html_url":"https://github.com/vkurennov","followers_url":"https://api.github.com/users/vkurennov/followers","following_url":"https://api.github.com/users/vkurennov/following{/other_user}","gists_url":"https://api.github.com/users/vkurennov/gists{/gist_id}","starred_url":"https://api.github.com/users/vkurennov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkurennov/subscriptions","organizations_url":"https://api.github.com/users/vkurennov/orgs","repos_url":"https://api.github.com/users/vkurennov/repos","events_url":"https://api.github.com/users/vkurennov/events{/privacy}","received_events_url":"https://api.github.com/users/vkurennov/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/boutsko/qna/pulls/8/commits","review_comments_url":"https://api.github.com/repos/boutsko/qna/pulls/8/comments","review_comment_url":"https://api.github.com/repos/boutsko/qna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/boutsko/qna/issues/8/comments","statuses_url":"https://api.github.com/repos/boutsko/qna/statuses/9caec4ca8dbc7176796ca3f57ed78f40f139527d","head":{"label":"boutsko:lesson9","ref":"lesson9","sha":"9caec4ca8dbc7176796ca3f57ed78f40f139527d","user":{"login":"boutsko","id":11396261,"avatar_url":"https://avatars.githubusercontent.com/u/11396261?v=3","gravatar_id":"","url":"https://api.github.com/users/boutsko","html_url":"https://github.com/boutsko","followers_url":"https://api.github.com/users/boutsko/followers","following_url":"https://api.github.com/users/boutsko/following{/other_user}","gists_url":"https://api.github.com/users/boutsko/gists{/gist_id}","starred_url":"https://api.github.com/users/boutsko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boutsko/subscriptions","organizations_url":"https://api.github.com/users/boutsko/orgs","repos_url":"https://api.github.com/users/boutsko/repos","events_url":"https://api.github.com/users/boutsko/events{/privacy}","received_events_url":"https://api.github.com/users/boutsko/received_events","type":"User","site_admin":false},"repo":{"id":31931038,"name":"qna","full_name":"boutsko/qna","owner":{"login":"boutsko","id":11396261,"avatar_url":"https://avatars.githubusercontent.com/u/11396261?v=3","gravatar_id":"","url":"https://api.github.com/users/boutsko","html_url":"https://github.com/boutsko","followers_url":"https://api.github.com/users/boutsko/followers","following_url":"https://api.github.com/users/boutsko/following{/other_user}","gists_url":"https://api.github.com/users/boutsko/gists{/gist_id}","starred_url":"https://api.github.com/users/boutsko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boutsko/subscriptions","organizations_url":"https://api.github.com/users/boutsko/orgs","repos_url":"https://api.github.com/users/boutsko/repos","events_url":"https://api.github.com/users/boutsko/events{/privacy}","received_events_url":"https://api.github.com/users/boutsko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/boutsko/qna","description":"QnA sample","fork":false,"url":"https://api.github.com/repos/boutsko/qna","forks_url":"https://api.github.com/repos/boutsko/qna/forks","keys_url":"https://api.github.com/repos/boutsko/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boutsko/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boutsko/qna/teams","hooks_url":"https://api.github.com/repos/boutsko/qna/hooks","issue_events_url":"https://api.github.com/repos/boutsko/qna/issues/events{/number}","events_url":"https://api.github.com/repos/boutsko/qna/events","assignees_url":"https://api.github.com/repos/boutsko/qna/assignees{/user}","branches_url":"https://api.github.com/repos/boutsko/qna/branches{/branch}","tags_url":"https://api.github.com/repos/boutsko/qna/tags","blobs_url":"https://api.github.com/repos/boutsko/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boutsko/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boutsko/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/boutsko/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boutsko/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/boutsko/qna/languages","stargazers_url":"https://api.github.com/repos/boutsko/qna/stargazers","contributors_url":"https://api.github.com/repos/boutsko/qna/contributors","subscribers_url":"https://api.github.com/repos/boutsko/qna/subscribers","subscription_url":"https://api.github.com/repos/boutsko/qna/subscription","commits_url":"https://api.github.com/repos/boutsko/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/boutsko/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/boutsko/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/boutsko/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/boutsko/qna/contents/{+path}","compare_url":"https://api.github.com/repos/boutsko/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boutsko/qna/merges","archive_url":"https://api.github.com/repos/boutsko/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boutsko/qna/downloads","issues_url":"https://api.github.com/repos/boutsko/qna/issues{/number}","pulls_url":"https://api.github.com/repos/boutsko/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/boutsko/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/boutsko/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boutsko/qna/labels{/name}","releases_url":"https://api.github.com/repos/boutsko/qna/releases{/id}","created_at":"2015-03-10T01:01:45Z","updated_at":"2015-04-21T07:46:08Z","pushed_at":"2015-04-29T16:32:12Z","git_url":"git://github.com/boutsko/qna.git","ssh_url":"git@github.com:boutsko/qna.git","clone_url":"https://github.com/boutsko/qna.git","svn_url":"https://github.com/boutsko/qna","homepage":"","size":736,"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":"boutsko:master","ref":"master","sha":"7ac879a46d4d947cff4b3cae4fea0da39f02cffa","user":{"login":"boutsko","id":11396261,"avatar_url":"https://avatars.githubusercontent.com/u/11396261?v=3","gravatar_id":"","url":"https://api.github.com/users/boutsko","html_url":"https://github.com/boutsko","followers_url":"https://api.github.com/users/boutsko/followers","following_url":"https://api.github.com/users/boutsko/following{/other_user}","gists_url":"https://api.github.com/users/boutsko/gists{/gist_id}","starred_url":"https://api.github.com/users/boutsko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boutsko/subscriptions","organizations_url":"https://api.github.com/users/boutsko/orgs","repos_url":"https://api.github.com/users/boutsko/repos","events_url":"https://api.github.com/users/boutsko/events{/privacy}","received_events_url":"https://api.github.com/users/boutsko/received_events","type":"User","site_admin":false},"repo":{"id":31931038,"name":"qna","full_name":"boutsko/qna","owner":{"login":"boutsko","id":11396261,"avatar_url":"https://avatars.githubusercontent.com/u/11396261?v=3","gravatar_id":"","url":"https://api.github.com/users/boutsko","html_url":"https://github.com/boutsko","followers_url":"https://api.github.com/users/boutsko/followers","following_url":"https://api.github.com/users/boutsko/following{/other_user}","gists_url":"https://api.github.com/users/boutsko/gists{/gist_id}","starred_url":"https://api.github.com/users/boutsko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boutsko/subscriptions","organizations_url":"https://api.github.com/users/boutsko/orgs","repos_url":"https://api.github.com/users/boutsko/repos","events_url":"https://api.github.com/users/boutsko/events{/privacy}","received_events_url":"https://api.github.com/users/boutsko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/boutsko/qna","description":"QnA sample","fork":false,"url":"https://api.github.com/repos/boutsko/qna","forks_url":"https://api.github.com/repos/boutsko/qna/forks","keys_url":"https://api.github.com/repos/boutsko/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boutsko/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boutsko/qna/teams","hooks_url":"https://api.github.com/repos/boutsko/qna/hooks","issue_events_url":"https://api.github.com/repos/boutsko/qna/issues/events{/number}","events_url":"https://api.github.com/repos/boutsko/qna/events","assignees_url":"https://api.github.com/repos/boutsko/qna/assignees{/user}","branches_url":"https://api.github.com/repos/boutsko/qna/branches{/branch}","tags_url":"https://api.github.com/repos/boutsko/qna/tags","blobs_url":"https://api.github.com/repos/boutsko/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boutsko/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boutsko/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/boutsko/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boutsko/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/boutsko/qna/languages","stargazers_url":"https://api.github.com/repos/boutsko/qna/stargazers","contributors_url":"https://api.github.com/repos/boutsko/qna/contributors","subscribers_url":"https://api.github.com/repos/boutsko/qna/subscribers","subscription_url":"https://api.github.com/repos/boutsko/qna/subscription","commits_url":"https://api.github.com/repos/boutsko/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/boutsko/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/boutsko/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/boutsko/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/boutsko/qna/contents/{+path}","compare_url":"https://api.github.com/repos/boutsko/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boutsko/qna/merges","archive_url":"https://api.github.com/repos/boutsko/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boutsko/qna/downloads","issues_url":"https://api.github.com/repos/boutsko/qna/issues{/number}","pulls_url":"https://api.github.com/repos/boutsko/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/boutsko/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/boutsko/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boutsko/qna/labels{/name}","releases_url":"https://api.github.com/repos/boutsko/qna/releases{/id}","created_at":"2015-03-10T01:01:45Z","updated_at":"2015-04-21T07:46:08Z","pushed_at":"2015-04-29T16:32:12Z","git_url":"git://github.com/boutsko/qna.git","ssh_url":"git@github.com:boutsko/qna.git","clone_url":"https://github.com/boutsko/qna.git","svn_url":"https://github.com/boutsko/qna","homepage":"","size":736,"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/boutsko/qna/pulls/8"},"html":{"href":"https://github.com/boutsko/qna/pull/8"},"issue":{"href":"https://api.github.com/repos/boutsko/qna/issues/8"},"comments":{"href":"https://api.github.com/repos/boutsko/qna/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/boutsko/qna/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/boutsko/qna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/boutsko/qna/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/boutsko/qna/statuses/9caec4ca8dbc7176796ca3f57ed78f40f139527d"}}}}