{"action":"created","comment":{"url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/comments/51344946","id":51344946,"diff_hunk":"@@ -0,0 +1,87 @@\n+class UsersController < ApplicationController\n+  include ProviderHelper\n+  before_action :set_user, only: [:show, :update, :destroy, :questions, :tags]\n+\n+  def index\n+    @users = User.paginate(page: params[:page])\n+    render json: @users, status: :ok\n+\n+    # add meta data for pagination\n+    # total: resource.total_entries,\n+    # total_pages: resource.total_pages,\n+    # first_page: resource.current_page == 1,\n+    # last_page: resource.next_page.blank?,\n+    # previous_page: resource.previous_page,\n+    # next_page: resource.next_page,\n+    # out_of_bounds: resource.out_of_bounds?,\n+    # offset: resource.offset\n+  end\n+\n+  def show\n+    render json: @user, status: :ok\n+  end\n+\n+\n+  def update\n+    if @user.update(user_params)\n+      head :no_content\n+    else @user.errors\n+      render json: @user.errors, status: :unprocessable_entity\n+    end\n+  end\n+\n+  def destroy\n+    @user.destroy\n+    head :no_content\n+  end\n+\n+  def login\n+    redirect_url = params[:redirect_url] || params[:rdr] || params[:redir]\n+    provider = get_provider(params[:provider] || params[:p])\n+    set_attrs_in_session({redirect_url: redirect_url})\n+\n+    redirect_to provider\n+  end\n+\n+  def authenticate\n+    @current_user = User.from_omniauth(env[\"omniauth.auth\"])\n+    @current_user.update(active: true)\n+    token = @current_user.refresh_token\n+    redirect_url = get_attrs_from_session([:redirect_url]).first\n+\n+    session.clear\n+    redirect_to redirect_url\n+    \n+  end\n+\n+\n+  def renew_token\n+    token = current_user.refresh_token\n+    render json: {api_key: token}, status: :ok\n+  end\n+\n+  def logout\n+    current_user.update(active: false)\n+    head :no_content\n+  end\n+\n+  def questions\n+    @user.questions.paginate(page: params[:page])\n+  end\n+\n+  def tags\n+    @user.subscribed_tags\n+  end\n+\n+  private\n+\n+\n+    def set_user\n+      @user = User.find_by(id: params[:id])\n+      resource_not_found and return unless @user","path":"app/controllers/users_controller.rb","position":81,"original_position":81,"commit_id":"1b8b0ae83c24b59490b7cfcdf7ae5b69d7c43e6e","original_commit_id":"1b8b0ae83c24b59490b7cfcdf7ae5b69d7c43e6e","user":{"login":"andela-ooranagwa","id":11221027,"avatar_url":"https://avatars.githubusercontent.com/u/11221027?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-ooranagwa","html_url":"https://github.com/andela-ooranagwa","followers_url":"https://api.github.com/users/andela-ooranagwa/followers","following_url":"https://api.github.com/users/andela-ooranagwa/following{/other_user}","gists_url":"https://api.github.com/users/andela-ooranagwa/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-ooranagwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-ooranagwa/subscriptions","organizations_url":"https://api.github.com/users/andela-ooranagwa/orgs","repos_url":"https://api.github.com/users/andela-ooranagwa/repos","events_url":"https://api.github.com/users/andela-ooranagwa/events{/privacy}","received_events_url":"https://api.github.com/users/andela-ooranagwa/received_events","type":"User","site_admin":false},"body":"No sure though, but I think the use of `and` is *deprecated*","created_at":"2016-01-30T13:29:29Z","updated_at":"2016-01-30T13:29:29Z","html_url":"https://github.com/andela-iamadi/zhishi-backend/pull/12#discussion_r51344946","pull_request_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/comments/51344946"},"html":{"href":"https://github.com/andela-iamadi/zhishi-backend/pull/12#discussion_r51344946"},"pull_request":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12","id":57677231,"html_url":"https://github.com/andela-iamadi/zhishi-backend/pull/12","diff_url":"https://github.com/andela-iamadi/zhishi-backend/pull/12.diff","patch_url":"https://github.com/andela-iamadi/zhishi-backend/pull/12.patch","issue_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/12","number":12,"state":"open","locked":false,"title":"User implementation","user":{"login":"andela-oakinniranye","id":12733004,"avatar_url":"https://avatars.githubusercontent.com/u/12733004?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-oakinniranye","html_url":"https://github.com/andela-oakinniranye","followers_url":"https://api.github.com/users/andela-oakinniranye/followers","following_url":"https://api.github.com/users/andela-oakinniranye/following{/other_user}","gists_url":"https://api.github.com/users/andela-oakinniranye/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-oakinniranye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-oakinniranye/subscriptions","organizations_url":"https://api.github.com/users/andela-oakinniranye/orgs","repos_url":"https://api.github.com/users/andela-oakinniranye/repos","events_url":"https://api.github.com/users/andela-oakinniranye/events{/privacy}","received_events_url":"https://api.github.com/users/andela-oakinniranye/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-29T17:29:29Z","updated_at":"2016-01-30T13:29:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"25b1dd838fe13d10117bbd495c71d1df2b85484f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12/commits","review_comments_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12/comments","review_comment_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/12/comments","statuses_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/statuses/1b8b0ae83c24b59490b7cfcdf7ae5b69d7c43e6e","head":{"label":"andela-iamadi:user_implementation","ref":"user_implementation","sha":"1b8b0ae83c24b59490b7cfcdf7ae5b69d7c43e6e","user":{"login":"andela-iamadi","id":12391897,"avatar_url":"https://avatars.githubusercontent.com/u/12391897?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-iamadi","html_url":"https://github.com/andela-iamadi","followers_url":"https://api.github.com/users/andela-iamadi/followers","following_url":"https://api.github.com/users/andela-iamadi/following{/other_user}","gists_url":"https://api.github.com/users/andela-iamadi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-iamadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-iamadi/subscriptions","organizations_url":"https://api.github.com/users/andela-iamadi/orgs","repos_url":"https://api.github.com/users/andela-iamadi/repos","events_url":"https://api.github.com/users/andela-iamadi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-iamadi/received_events","type":"User","site_admin":false},"repo":{"id":49574351,"name":"zhishi-backend","full_name":"andela-iamadi/zhishi-backend","owner":{"login":"andela-iamadi","id":12391897,"avatar_url":"https://avatars.githubusercontent.com/u/12391897?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-iamadi","html_url":"https://github.com/andela-iamadi","followers_url":"https://api.github.com/users/andela-iamadi/followers","following_url":"https://api.github.com/users/andela-iamadi/following{/other_user}","gists_url":"https://api.github.com/users/andela-iamadi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-iamadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-iamadi/subscriptions","organizations_url":"https://api.github.com/users/andela-iamadi/orgs","repos_url":"https://api.github.com/users/andela-iamadi/repos","events_url":"https://api.github.com/users/andela-iamadi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-iamadi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-iamadi/zhishi-backend","description":"A backend for zhishi question and answer forum","fork":false,"url":"https://api.github.com/repos/andela-iamadi/zhishi-backend","forks_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/forks","keys_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/teams","hooks_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/hooks","issue_events_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/events{/number}","events_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/events","assignees_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/assignees{/user}","branches_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/branches{/branch}","tags_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/tags","blobs_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/languages","stargazers_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/stargazers","contributors_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/contributors","subscribers_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/subscribers","subscription_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/subscription","commits_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/contents/{+path}","compare_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/merges","archive_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/downloads","issues_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues{/number}","pulls_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/labels{/name}","releases_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/releases{/id}","deployments_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/deployments","created_at":"2016-01-13T13:07:52Z","updated_at":"2016-01-14T12:11:10Z","pushed_at":"2016-01-30T09:13:34Z","git_url":"git://github.com/andela-iamadi/zhishi-backend.git","ssh_url":"git@github.com:andela-iamadi/zhishi-backend.git","clone_url":"https://github.com/andela-iamadi/zhishi-backend.git","svn_url":"https://github.com/andela-iamadi/zhishi-backend","homepage":null,"size":177,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-iamadi:master","ref":"master","sha":"026cdfe5ece6f16c382811ead0f9a950f2e3e8c0","user":{"login":"andela-iamadi","id":12391897,"avatar_url":"https://avatars.githubusercontent.com/u/12391897?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-iamadi","html_url":"https://github.com/andela-iamadi","followers_url":"https://api.github.com/users/andela-iamadi/followers","following_url":"https://api.github.com/users/andela-iamadi/following{/other_user}","gists_url":"https://api.github.com/users/andela-iamadi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-iamadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-iamadi/subscriptions","organizations_url":"https://api.github.com/users/andela-iamadi/orgs","repos_url":"https://api.github.com/users/andela-iamadi/repos","events_url":"https://api.github.com/users/andela-iamadi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-iamadi/received_events","type":"User","site_admin":false},"repo":{"id":49574351,"name":"zhishi-backend","full_name":"andela-iamadi/zhishi-backend","owner":{"login":"andela-iamadi","id":12391897,"avatar_url":"https://avatars.githubusercontent.com/u/12391897?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-iamadi","html_url":"https://github.com/andela-iamadi","followers_url":"https://api.github.com/users/andela-iamadi/followers","following_url":"https://api.github.com/users/andela-iamadi/following{/other_user}","gists_url":"https://api.github.com/users/andela-iamadi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-iamadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-iamadi/subscriptions","organizations_url":"https://api.github.com/users/andela-iamadi/orgs","repos_url":"https://api.github.com/users/andela-iamadi/repos","events_url":"https://api.github.com/users/andela-iamadi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-iamadi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-iamadi/zhishi-backend","description":"A backend for zhishi question and answer forum","fork":false,"url":"https://api.github.com/repos/andela-iamadi/zhishi-backend","forks_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/forks","keys_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/teams","hooks_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/hooks","issue_events_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/events{/number}","events_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/events","assignees_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/assignees{/user}","branches_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/branches{/branch}","tags_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/tags","blobs_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/languages","stargazers_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/stargazers","contributors_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/contributors","subscribers_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/subscribers","subscription_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/subscription","commits_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/contents/{+path}","compare_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/merges","archive_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/downloads","issues_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues{/number}","pulls_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/labels{/name}","releases_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/releases{/id}","deployments_url":"https://api.github.com/repos/andela-iamadi/zhishi-backend/deployments","created_at":"2016-01-13T13:07:52Z","updated_at":"2016-01-14T12:11:10Z","pushed_at":"2016-01-30T09:13:34Z","git_url":"git://github.com/andela-iamadi/zhishi-backend.git","ssh_url":"git@github.com:andela-iamadi/zhishi-backend.git","clone_url":"https://github.com/andela-iamadi/zhishi-backend.git","svn_url":"https://github.com/andela-iamadi/zhishi-backend","homepage":null,"size":177,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12"},"html":{"href":"https://github.com/andela-iamadi/zhishi-backend/pull/12"},"issue":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/12"},"comments":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/andela-iamadi/zhishi-backend/statuses/1b8b0ae83c24b59490b7cfcdf7ae5b69d7c43e6e"}}}}