{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_194/pulls/comments/83773635","pull_request_review_id":4594204,"id":83773635,"diff_hunk":"@@ -0,0 +1,70 @@\n+class LessonsController < ApplicationController\n+  before_action :require_log_in\n+  before_action :load_lesson, :check_user_lesson_permisson, only: [:edit, :show, :update]\n+  before_action :check_completed, only: [:edit, :update]\n+  before_action :check_uncompleted, only: :show\n+\n+  def create\n+    @lesson = Lesson.new category_id: params[:category_id],\n+      user_id: current_user.id\n+    if @lesson.save\n+      flash[:success] = t \".success\"\n+      redirect_to edit_lesson_path @lesson\n+    else\n+      flash[:danger] = @lesson.errors.full_messages\n+      redirect_to categories_path\n+    end\n+  end\n+\n+  def edit\n+  end\n+\n+  def show\n+  end\n+\n+  def update\n+    completed_lesson_params = lesson_params\n+    completed_lesson_params[:is_completed] = true\n+    if @lesson.update_attributes completed_lesson_params\n+      flash[:success] = t \".success\"\n+      redirect_to lesson_path @lesson\n+    else\n+      flash[:danger] = t \".failed\"\n+      redirect_to edit_lesson_path @lesson\n+    end\n+  end\n+\n+  private\n+  def load_lesson\n+    @lesson = Lesson.find_by id: params[:id]\n+    unless @lesson\n+      flash[:danger] = t \".invalid_lesson\"\n+      redirect_to categories_path\n+    end\n+  end\n+\n+  def check_user_lesson_permisson\n+    unless current_user.is_user? @lesson.user\n+      flash[:danger] = t \".denied\"\n+      redirect_to root_url\n+    end\n+  end\n+\n+  def check_completed\n+    if @lesson.is_completed?\n+      flash[:danger] = t \".finished\"\n+      redirect_to current_user","path":"app/controllers/lessons_controller.rb","position":56,"original_position":56,"commit_id":"eead1001db1d701149407d9c7f2c01f6b099abc9","original_commit_id":"eead1001db1d701149407d9c7f2c01f6b099abc9","user":{"login":"hongsondhs","id":22186548,"avatar_url":"https://avatars.githubusercontent.com/u/22186548?v=3","gravatar_id":"","url":"https://api.github.com/users/hongsondhs","html_url":"https://github.com/hongsondhs","followers_url":"https://api.github.com/users/hongsondhs/followers","following_url":"https://api.github.com/users/hongsondhs/following{/other_user}","gists_url":"https://api.github.com/users/hongsondhs/gists{/gist_id}","starred_url":"https://api.github.com/users/hongsondhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hongsondhs/subscriptions","organizations_url":"https://api.github.com/users/hongsondhs/orgs","repos_url":"https://api.github.com/users/hongsondhs/repos","events_url":"https://api.github.com/users/hongsondhs/events{/privacy}","received_events_url":"https://api.github.com/users/hongsondhs/received_events","type":"User","site_admin":false},"body":"trả lời giống câu dưới","created_at":"2016-10-18T02:51:27Z","updated_at":"2016-10-18T02:51:27Z","html_url":"https://github.com/framgia/fels_194/pull/16#discussion_r83773635","pull_request_url":"https://api.github.com/repos/framgia/fels_194/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_194/pulls/comments/83773635"},"html":{"href":"https://github.com/framgia/fels_194/pull/16#discussion_r83773635"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_194/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_194/pulls/16","id":89558903,"html_url":"https://github.com/framgia/fels_194/pull/16","diff_url":"https://github.com/framgia/fels_194/pull/16.diff","patch_url":"https://github.com/framgia/fels_194/pull/16.patch","issue_url":"https://api.github.com/repos/framgia/fels_194/issues/16","number":16,"state":"open","locked":false,"title":"Create-lesson","user":{"login":"hongsondhs","id":22186548,"avatar_url":"https://avatars.githubusercontent.com/u/22186548?v=3","gravatar_id":"","url":"https://api.github.com/users/hongsondhs","html_url":"https://github.com/hongsondhs","followers_url":"https://api.github.com/users/hongsondhs/followers","following_url":"https://api.github.com/users/hongsondhs/following{/other_user}","gists_url":"https://api.github.com/users/hongsondhs/gists{/gist_id}","starred_url":"https://api.github.com/users/hongsondhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hongsondhs/subscriptions","organizations_url":"https://api.github.com/users/hongsondhs/orgs","repos_url":"https://api.github.com/users/hongsondhs/repos","events_url":"https://api.github.com/users/hongsondhs/events{/privacy}","received_events_url":"https://api.github.com/users/hongsondhs/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-17T04:21:18Z","updated_at":"2016-10-18T02:51:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea057f06710ad02361d4f80df3c1ae5707b25376","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_194/pulls/16/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_194/pulls/16/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_194/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_194/issues/16/comments","statuses_url":"https://api.github.com/repos/framgia/fels_194/statuses/eead1001db1d701149407d9c7f2c01f6b099abc9","head":{"label":"hongsondhs:create-lesson","ref":"create-lesson","sha":"eead1001db1d701149407d9c7f2c01f6b099abc9","user":{"login":"hongsondhs","id":22186548,"avatar_url":"https://avatars.githubusercontent.com/u/22186548?v=3","gravatar_id":"","url":"https://api.github.com/users/hongsondhs","html_url":"https://github.com/hongsondhs","followers_url":"https://api.github.com/users/hongsondhs/followers","following_url":"https://api.github.com/users/hongsondhs/following{/other_user}","gists_url":"https://api.github.com/users/hongsondhs/gists{/gist_id}","starred_url":"https://api.github.com/users/hongsondhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hongsondhs/subscriptions","organizations_url":"https://api.github.com/users/hongsondhs/orgs","repos_url":"https://api.github.com/users/hongsondhs/repos","events_url":"https://api.github.com/users/hongsondhs/events{/privacy}","received_events_url":"https://api.github.com/users/hongsondhs/received_events","type":"User","site_admin":false},"repo":{"id":70049305,"name":"fels_194","full_name":"hongsondhs/fels_194","owner":{"login":"hongsondhs","id":22186548,"avatar_url":"https://avatars.githubusercontent.com/u/22186548?v=3","gravatar_id":"","url":"https://api.github.com/users/hongsondhs","html_url":"https://github.com/hongsondhs","followers_url":"https://api.github.com/users/hongsondhs/followers","following_url":"https://api.github.com/users/hongsondhs/following{/other_user}","gists_url":"https://api.github.com/users/hongsondhs/gists{/gist_id}","starred_url":"https://api.github.com/users/hongsondhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hongsondhs/subscriptions","organizations_url":"https://api.github.com/users/hongsondhs/orgs","repos_url":"https://api.github.com/users/hongsondhs/repos","events_url":"https://api.github.com/users/hongsondhs/events{/privacy}","received_events_url":"https://api.github.com/users/hongsondhs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hongsondhs/fels_194","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/hongsondhs/fels_194","forks_url":"https://api.github.com/repos/hongsondhs/fels_194/forks","keys_url":"https://api.github.com/repos/hongsondhs/fels_194/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hongsondhs/fels_194/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hongsondhs/fels_194/teams","hooks_url":"https://api.github.com/repos/hongsondhs/fels_194/hooks","issue_events_url":"https://api.github.com/repos/hongsondhs/fels_194/issues/events{/number}","events_url":"https://api.github.com/repos/hongsondhs/fels_194/events","assignees_url":"https://api.github.com/repos/hongsondhs/fels_194/assignees{/user}","branches_url":"https://api.github.com/repos/hongsondhs/fels_194/branches{/branch}","tags_url":"https://api.github.com/repos/hongsondhs/fels_194/tags","blobs_url":"https://api.github.com/repos/hongsondhs/fels_194/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hongsondhs/fels_194/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hongsondhs/fels_194/git/refs{/sha}","trees_url":"https://api.github.com/repos/hongsondhs/fels_194/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hongsondhs/fels_194/statuses/{sha}","languages_url":"https://api.github.com/repos/hongsondhs/fels_194/languages","stargazers_url":"https://api.github.com/repos/hongsondhs/fels_194/stargazers","contributors_url":"https://api.github.com/repos/hongsondhs/fels_194/contributors","subscribers_url":"https://api.github.com/repos/hongsondhs/fels_194/subscribers","subscription_url":"https://api.github.com/repos/hongsondhs/fels_194/subscription","commits_url":"https://api.github.com/repos/hongsondhs/fels_194/commits{/sha}","git_commits_url":"https://api.github.com/repos/hongsondhs/fels_194/git/commits{/sha}","comments_url":"https://api.github.com/repos/hongsondhs/fels_194/comments{/number}","issue_comment_url":"https://api.github.com/repos/hongsondhs/fels_194/issues/comments{/number}","contents_url":"https://api.github.com/repos/hongsondhs/fels_194/contents/{+path}","compare_url":"https://api.github.com/repos/hongsondhs/fels_194/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hongsondhs/fels_194/merges","archive_url":"https://api.github.com/repos/hongsondhs/fels_194/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hongsondhs/fels_194/downloads","issues_url":"https://api.github.com/repos/hongsondhs/fels_194/issues{/number}","pulls_url":"https://api.github.com/repos/hongsondhs/fels_194/pulls{/number}","milestones_url":"https://api.github.com/repos/hongsondhs/fels_194/milestones{/number}","notifications_url":"https://api.github.com/repos/hongsondhs/fels_194/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hongsondhs/fels_194/labels{/name}","releases_url":"https://api.github.com/repos/hongsondhs/fels_194/releases{/id}","deployments_url":"https://api.github.com/repos/hongsondhs/fels_194/deployments","created_at":"2016-10-05T10:10:55Z","updated_at":"2016-10-05T07:30:53Z","pushed_at":"2016-10-18T01:36:43Z","git_url":"git://github.com/hongsondhs/fels_194.git","ssh_url":"git@github.com:hongsondhs/fels_194.git","clone_url":"https://github.com/hongsondhs/fels_194.git","svn_url":"https://github.com/hongsondhs/fels_194","homepage":null,"size":71,"stargazers_count":0,"watchers_count":0,"language":null,"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":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"90bcdf8ed4de5ad8edf2d666148afb2ab2e13165","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":70038826,"name":"fels_194","full_name":"framgia/fels_194","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/fels_194","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_194","forks_url":"https://api.github.com/repos/framgia/fels_194/forks","keys_url":"https://api.github.com/repos/framgia/fels_194/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_194/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_194/teams","hooks_url":"https://api.github.com/repos/framgia/fels_194/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_194/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_194/events","assignees_url":"https://api.github.com/repos/framgia/fels_194/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_194/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_194/tags","blobs_url":"https://api.github.com/repos/framgia/fels_194/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_194/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_194/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_194/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_194/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_194/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_194/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_194/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_194/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_194/subscription","commits_url":"https://api.github.com/repos/framgia/fels_194/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_194/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_194/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_194/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_194/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_194/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_194/merges","archive_url":"https://api.github.com/repos/framgia/fels_194/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_194/downloads","issues_url":"https://api.github.com/repos/framgia/fels_194/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_194/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_194/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_194/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_194/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_194/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/fels_194/deployments","created_at":"2016-10-05T07:30:53Z","updated_at":"2016-10-05T07:30:53Z","pushed_at":"2016-10-18T01:36:43Z","git_url":"git://github.com/framgia/fels_194.git","ssh_url":"git@github.com:framgia/fels_194.git","clone_url":"https://github.com/framgia/fels_194.git","svn_url":"https://github.com/framgia/fels_194","homepage":null,"size":69,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_194/pulls/16"},"html":{"href":"https://github.com/framgia/fels_194/pull/16"},"issue":{"href":"https://api.github.com/repos/framgia/fels_194/issues/16"},"comments":{"href":"https://api.github.com/repos/framgia/fels_194/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_194/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_194/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_194/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_194/statuses/eead1001db1d701149407d9c7f2c01f6b099abc9"}}}}
{"actor":{"display_login":"hongsondhs"}}