{"action":"created","comment":{"url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/comments/173645486","pull_request_review_id":102873132,"id":173645486,"diff_hunk":"@@ -0,0 +1,65 @@\n+# frozen_string_literal: true\n+\n+class BlogsController < ApplicationController\n+  before_action :require_login, only: [:new, :create, :edit, :update, :destroy]\n+  def show\n+    @blog = Blog.find_by(name: params[:name])\n+    @articles = @blog.articles\n+  end\n+\n+  def new\n+    @blog = Blog.new\n+  end\n+\n+  def create\n+    @blog = Blog.new(blog_params)\n+    @blog.user_id = current_user.id\n+    if @blog.save\n+      redirect_to_blog(@blog)\n+    else\n+      render :new\n+    end\n+  end\n+\n+  def edit\n+    @blog = Blog.find(params[:id])\n+    redirect_to_blog unless authorized?(@blog)\n+  end\n+\n+  def update\n+    @blog = Blog.find(params[:id])\n+    if authorized?(@blog)\n+      if @blog.update_attributes(blog_params)\n+        redirect_to_blog(@blog)\n+      else\n+        render :edit\n+      end\n+    else\n+      redirect_to_blog(@blog)\n+    end\n+  end\n+\n+  def destroy\n+    blog = Blog.find(params[:id])\n+    if authorized?(blog)","path":"app/controllers/blogs_controller.rb","position":44,"original_position":44,"commit_id":"78cf158614aa9adbe491a65f5f60db60c0bcbc32","original_commit_id":"78cf158614aa9adbe491a65f5f60db60c0bcbc32","user":{"login":"rnitta","id":31783570,"avatar_url":"https://avatars1.githubusercontent.com/u/31783570?v=4","gravatar_id":"","url":"https://api.github.com/users/rnitta","html_url":"https://github.com/rnitta","followers_url":"https://api.github.com/users/rnitta/followers","following_url":"https://api.github.com/users/rnitta/following{/other_user}","gists_url":"https://api.github.com/users/rnitta/gists{/gist_id}","starred_url":"https://api.github.com/users/rnitta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnitta/subscriptions","organizations_url":"https://api.github.com/users/rnitta/orgs","repos_url":"https://api.github.com/users/rnitta/repos","events_url":"https://api.github.com/users/rnitta/events{/privacy}","received_events_url":"https://api.github.com/users/rnitta/received_events","type":"User","site_admin":false},"body":"https://github.com/rnitta/simple-blog-rails/pull/17/commits/3a678f4b772a4a9daec4088dc3b248755e5858db\r\nbefore_actionで@blogをセットするようにしました。","created_at":"2018-03-11T07:19:36Z","updated_at":"2018-03-11T07:19:36Z","html_url":"https://github.com/rnitta/simple-blog-rails/pull/13#discussion_r173645486","pull_request_url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/comments/173645486"},"html":{"href":"https://github.com/rnitta/simple-blog-rails/pull/13#discussion_r173645486"},"pull_request":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13"}},"in_reply_to_id":172387510},"pull_request":{"url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13","id":172678687,"html_url":"https://github.com/rnitta/simple-blog-rails/pull/13","diff_url":"https://github.com/rnitta/simple-blog-rails/pull/13.diff","patch_url":"https://github.com/rnitta/simple-blog-rails/pull/13.patch","issue_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/13","number":13,"state":"open","locked":false,"title":"Blogsコントローラを追加","user":{"login":"rnitta","id":31783570,"avatar_url":"https://avatars1.githubusercontent.com/u/31783570?v=4","gravatar_id":"","url":"https://api.github.com/users/rnitta","html_url":"https://github.com/rnitta","followers_url":"https://api.github.com/users/rnitta/followers","following_url":"https://api.github.com/users/rnitta/following{/other_user}","gists_url":"https://api.github.com/users/rnitta/gists{/gist_id}","starred_url":"https://api.github.com/users/rnitta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnitta/subscriptions","organizations_url":"https://api.github.com/users/rnitta/orgs","repos_url":"https://api.github.com/users/rnitta/repos","events_url":"https://api.github.com/users/rnitta/events{/privacy}","received_events_url":"https://api.github.com/users/rnitta/received_events","type":"User","site_admin":false},"body":"## 作業内容:hatched_chick:\r\n\r\n- index以外のアクション(show, new, create, edit, update, destroy)を作成\r\n- ルーティングを追加\r\nshowアクションのみurlにnameカラムを使う関係上、\r\n例えばnameにnew等の予約語?を保存するとパスが被るので\r\n`/blogs/~~~`ではなく`/blog/~~~`に設定\r\n- ブログ作成ユーザー以外がedit, update, destroyできないように設定\r\n- showに記事タイトル一覧を表示\r\n\r\n追加したメソッド説明\r\n- blog_params\r\nストロングパラメータ用\r\n- redirect_to_blog(blog)\r\nredirect_to(blog)だと`/blogs/:id`に飛んでしまうので、\r\n'/blog/:name'に飛ばすためのもの\r\n- authorized?(blog)\r\n編集・削除する際に、カレントユーザーが作成ユーザーかどうか判定するもの。\r\n\r\n## 動作確認項目:eyes:\r\nなし\r\n\r\n## 進歩状況:clipboard:\r\n> - [x] PR作成\r\n> - [ ] レビュー依頼\r\n","created_at":"2018-03-03T17:46:45Z","updated_at":"2018-03-11T07:19:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bead538716f560f3004ebcefaf35088d713070f0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13/commits","review_comments_url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13/comments","review_comment_url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/13/comments","statuses_url":"https://api.github.com/repos/rnitta/simple-blog-rails/statuses/78cf158614aa9adbe491a65f5f60db60c0bcbc32","head":{"label":"rnitta:feature/create-blogs-controller","ref":"feature/create-blogs-controller","sha":"78cf158614aa9adbe491a65f5f60db60c0bcbc32","user":{"login":"rnitta","id":31783570,"avatar_url":"https://avatars1.githubusercontent.com/u/31783570?v=4","gravatar_id":"","url":"https://api.github.com/users/rnitta","html_url":"https://github.com/rnitta","followers_url":"https://api.github.com/users/rnitta/followers","following_url":"https://api.github.com/users/rnitta/following{/other_user}","gists_url":"https://api.github.com/users/rnitta/gists{/gist_id}","starred_url":"https://api.github.com/users/rnitta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnitta/subscriptions","organizations_url":"https://api.github.com/users/rnitta/orgs","repos_url":"https://api.github.com/users/rnitta/repos","events_url":"https://api.github.com/users/rnitta/events{/privacy}","received_events_url":"https://api.github.com/users/rnitta/received_events","type":"User","site_admin":false},"repo":{"id":121722471,"name":"simple-blog-rails","full_name":"rnitta/simple-blog-rails","owner":{"login":"rnitta","id":31783570,"avatar_url":"https://avatars1.githubusercontent.com/u/31783570?v=4","gravatar_id":"","url":"https://api.github.com/users/rnitta","html_url":"https://github.com/rnitta","followers_url":"https://api.github.com/users/rnitta/followers","following_url":"https://api.github.com/users/rnitta/following{/other_user}","gists_url":"https://api.github.com/users/rnitta/gists{/gist_id}","starred_url":"https://api.github.com/users/rnitta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnitta/subscriptions","organizations_url":"https://api.github.com/users/rnitta/orgs","repos_url":"https://api.github.com/users/rnitta/repos","events_url":"https://api.github.com/users/rnitta/events{/privacy}","received_events_url":"https://api.github.com/users/rnitta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rnitta/simple-blog-rails","description":null,"fork":false,"url":"https://api.github.com/repos/rnitta/simple-blog-rails","forks_url":"https://api.github.com/repos/rnitta/simple-blog-rails/forks","keys_url":"https://api.github.com/repos/rnitta/simple-blog-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rnitta/simple-blog-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rnitta/simple-blog-rails/teams","hooks_url":"https://api.github.com/repos/rnitta/simple-blog-rails/hooks","issue_events_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/events{/number}","events_url":"https://api.github.com/repos/rnitta/simple-blog-rails/events","assignees_url":"https://api.github.com/repos/rnitta/simple-blog-rails/assignees{/user}","branches_url":"https://api.github.com/repos/rnitta/simple-blog-rails/branches{/branch}","tags_url":"https://api.github.com/repos/rnitta/simple-blog-rails/tags","blobs_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rnitta/simple-blog-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rnitta/simple-blog-rails/languages","stargazers_url":"https://api.github.com/repos/rnitta/simple-blog-rails/stargazers","contributors_url":"https://api.github.com/repos/rnitta/simple-blog-rails/contributors","subscribers_url":"https://api.github.com/repos/rnitta/simple-blog-rails/subscribers","subscription_url":"https://api.github.com/repos/rnitta/simple-blog-rails/subscription","commits_url":"https://api.github.com/repos/rnitta/simple-blog-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rnitta/simple-blog-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rnitta/simple-blog-rails/contents/{+path}","compare_url":"https://api.github.com/repos/rnitta/simple-blog-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rnitta/simple-blog-rails/merges","archive_url":"https://api.github.com/repos/rnitta/simple-blog-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rnitta/simple-blog-rails/downloads","issues_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues{/number}","pulls_url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rnitta/simple-blog-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rnitta/simple-blog-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rnitta/simple-blog-rails/labels{/name}","releases_url":"https://api.github.com/repos/rnitta/simple-blog-rails/releases{/id}","deployments_url":"https://api.github.com/repos/rnitta/simple-blog-rails/deployments","created_at":"2018-02-16T06:49:28Z","updated_at":"2018-02-16T07:19:07Z","pushed_at":"2018-03-11T07:15:49Z","git_url":"git://github.com/rnitta/simple-blog-rails.git","ssh_url":"git@github.com:rnitta/simple-blog-rails.git","clone_url":"https://github.com/rnitta/simple-blog-rails.git","svn_url":"https://github.com/rnitta/simple-blog-rails","homepage":null,"size":131,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"dev"}},"base":{"label":"rnitta:feature/create-article&category-model","ref":"feature/create-article&category-model","sha":"19ae857ea688d76a2e77540c5c5268ed9a718b1c","user":{"login":"rnitta","id":31783570,"avatar_url":"https://avatars1.githubusercontent.com/u/31783570?v=4","gravatar_id":"","url":"https://api.github.com/users/rnitta","html_url":"https://github.com/rnitta","followers_url":"https://api.github.com/users/rnitta/followers","following_url":"https://api.github.com/users/rnitta/following{/other_user}","gists_url":"https://api.github.com/users/rnitta/gists{/gist_id}","starred_url":"https://api.github.com/users/rnitta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnitta/subscriptions","organizations_url":"https://api.github.com/users/rnitta/orgs","repos_url":"https://api.github.com/users/rnitta/repos","events_url":"https://api.github.com/users/rnitta/events{/privacy}","received_events_url":"https://api.github.com/users/rnitta/received_events","type":"User","site_admin":false},"repo":{"id":121722471,"name":"simple-blog-rails","full_name":"rnitta/simple-blog-rails","owner":{"login":"rnitta","id":31783570,"avatar_url":"https://avatars1.githubusercontent.com/u/31783570?v=4","gravatar_id":"","url":"https://api.github.com/users/rnitta","html_url":"https://github.com/rnitta","followers_url":"https://api.github.com/users/rnitta/followers","following_url":"https://api.github.com/users/rnitta/following{/other_user}","gists_url":"https://api.github.com/users/rnitta/gists{/gist_id}","starred_url":"https://api.github.com/users/rnitta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnitta/subscriptions","organizations_url":"https://api.github.com/users/rnitta/orgs","repos_url":"https://api.github.com/users/rnitta/repos","events_url":"https://api.github.com/users/rnitta/events{/privacy}","received_events_url":"https://api.github.com/users/rnitta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rnitta/simple-blog-rails","description":null,"fork":false,"url":"https://api.github.com/repos/rnitta/simple-blog-rails","forks_url":"https://api.github.com/repos/rnitta/simple-blog-rails/forks","keys_url":"https://api.github.com/repos/rnitta/simple-blog-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rnitta/simple-blog-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rnitta/simple-blog-rails/teams","hooks_url":"https://api.github.com/repos/rnitta/simple-blog-rails/hooks","issue_events_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/events{/number}","events_url":"https://api.github.com/repos/rnitta/simple-blog-rails/events","assignees_url":"https://api.github.com/repos/rnitta/simple-blog-rails/assignees{/user}","branches_url":"https://api.github.com/repos/rnitta/simple-blog-rails/branches{/branch}","tags_url":"https://api.github.com/repos/rnitta/simple-blog-rails/tags","blobs_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rnitta/simple-blog-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rnitta/simple-blog-rails/languages","stargazers_url":"https://api.github.com/repos/rnitta/simple-blog-rails/stargazers","contributors_url":"https://api.github.com/repos/rnitta/simple-blog-rails/contributors","subscribers_url":"https://api.github.com/repos/rnitta/simple-blog-rails/subscribers","subscription_url":"https://api.github.com/repos/rnitta/simple-blog-rails/subscription","commits_url":"https://api.github.com/repos/rnitta/simple-blog-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rnitta/simple-blog-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rnitta/simple-blog-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rnitta/simple-blog-rails/contents/{+path}","compare_url":"https://api.github.com/repos/rnitta/simple-blog-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rnitta/simple-blog-rails/merges","archive_url":"https://api.github.com/repos/rnitta/simple-blog-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rnitta/simple-blog-rails/downloads","issues_url":"https://api.github.com/repos/rnitta/simple-blog-rails/issues{/number}","pulls_url":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rnitta/simple-blog-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rnitta/simple-blog-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rnitta/simple-blog-rails/labels{/name}","releases_url":"https://api.github.com/repos/rnitta/simple-blog-rails/releases{/id}","deployments_url":"https://api.github.com/repos/rnitta/simple-blog-rails/deployments","created_at":"2018-02-16T06:49:28Z","updated_at":"2018-02-16T07:19:07Z","pushed_at":"2018-03-11T07:15:49Z","git_url":"git://github.com/rnitta/simple-blog-rails.git","ssh_url":"git@github.com:rnitta/simple-blog-rails.git","clone_url":"https://github.com/rnitta/simple-blog-rails.git","svn_url":"https://github.com/rnitta/simple-blog-rails","homepage":null,"size":131,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13"},"html":{"href":"https://github.com/rnitta/simple-blog-rails/pull/13"},"issue":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/13"},"comments":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/rnitta/simple-blog-rails/statuses/78cf158614aa9adbe491a65f5f60db60c0bcbc32"}},"author_association":"OWNER"}}
{"actor":{"display_login":"rnitta"}}