{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_46/pulls/comments/28391816","id":28391816,"diff_hunk":"@@ -1,26 +1,32 @@\n class LessonsController < ApplicationController\n+  before_action :logined_in_user\n+\n+  def new\n+    @category = Category.find params[:category_id]\n+    @lesson = Lesson.new\n+    @lesson_words = @category.words.sample(10)\n+\n+    @lesson_words.each {|word| @lesson.results.build word: word}\n+  end\n+\n   def create\n-    category = Category.find params[:category_id]\n-    @lesson = current_user.lessons.build category_id: category.id\n+    @lesson = current_user.lessons.build lesson_params\n     if @lesson.save\n-      words = category.words\n-      words.sample(20).each do |word|\n-        result = @lesson.results.build word_id: word.id\n-        result.save\n-      end\n-      redirect_to lesson_path @lesson.id\n+      redirect_to @lesson\n     else\n-      flash[:danger] = \"Error\"\n-      redirect_to root_url\n+      redirect_to new_lesson_path lesson.category\n     end\n   end\n \n   def show\n     @lesson = Lesson.find params[:id]\n     @results = @lesson.results\n-    @words = Array.new\n-    @results.each do |result|\n-      @words.push result.word\n-    end\n+    @count = number_correct @results","path":"app/controllers/lessons_controller.rb","position":38,"original_position":38,"commit_id":"731df361af7c7eeb5efaacaf607cdfc1cbb36119","original_commit_id":"731df361af7c7eeb5efaacaf607cdfc1cbb36119","user":{"login":"chuanhtuan","id":5590771,"avatar_url":"https://avatars.githubusercontent.com/u/5590771?v=3","gravatar_id":"","url":"https://api.github.com/users/chuanhtuan","html_url":"https://github.com/chuanhtuan","followers_url":"https://api.github.com/users/chuanhtuan/followers","following_url":"https://api.github.com/users/chuanhtuan/following{/other_user}","gists_url":"https://api.github.com/users/chuanhtuan/gists{/gist_id}","starred_url":"https://api.github.com/users/chuanhtuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuanhtuan/subscriptions","organizations_url":"https://api.github.com/users/chuanhtuan/orgs","repos_url":"https://api.github.com/users/chuanhtuan/repos","events_url":"https://api.github.com/users/chuanhtuan/events{/privacy}","received_events_url":"https://api.github.com/users/chuanhtuan/received_events","type":"User","site_admin":false},"body":"nên dùng một trường trong table lesson để lưu đáp án thay vì phải query lại mỗi khi hiển thị","created_at":"2015-04-15T03:53:34Z","updated_at":"2015-04-15T03:53:34Z","html_url":"https://github.com/framgia/fels_46/pull/6#discussion_r28391816","pull_request_url":"https://api.github.com/repos/framgia/fels_46/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_46/pulls/comments/28391816"},"html":{"href":"https://github.com/framgia/fels_46/pull/6#discussion_r28391816"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_46/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_46/pulls/6","id":33134375,"html_url":"https://github.com/framgia/fels_46/pull/6","diff_url":"https://github.com/framgia/fels_46/pull/6.diff","patch_url":"https://github.com/framgia/fels_46/pull/6.patch","issue_url":"https://api.github.com/repos/framgia/fels_46/issues/6","number":6,"state":"open","locked":false,"title":"result","user":{"login":"HoangThiTuanDung","id":5584520,"avatar_url":"https://avatars.githubusercontent.com/u/5584520?v=3","gravatar_id":"","url":"https://api.github.com/users/HoangThiTuanDung","html_url":"https://github.com/HoangThiTuanDung","followers_url":"https://api.github.com/users/HoangThiTuanDung/followers","following_url":"https://api.github.com/users/HoangThiTuanDung/following{/other_user}","gists_url":"https://api.github.com/users/HoangThiTuanDung/gists{/gist_id}","starred_url":"https://api.github.com/users/HoangThiTuanDung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HoangThiTuanDung/subscriptions","organizations_url":"https://api.github.com/users/HoangThiTuanDung/orgs","repos_url":"https://api.github.com/users/HoangThiTuanDung/repos","events_url":"https://api.github.com/users/HoangThiTuanDung/events{/privacy}","received_events_url":"https://api.github.com/users/HoangThiTuanDung/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-13T03:54:14Z","updated_at":"2015-04-15T03:53:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78e557ba83779460cf8664d6ecfb3b8ee5ce6ed0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_46/pulls/6/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_46/pulls/6/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_46/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_46/issues/6/comments","statuses_url":"https://api.github.com/repos/framgia/fels_46/statuses/731df361af7c7eeb5efaacaf607cdfc1cbb36119","head":{"label":"HoangThiTuanDung:result","ref":"result","sha":"731df361af7c7eeb5efaacaf607cdfc1cbb36119","user":{"login":"HoangThiTuanDung","id":5584520,"avatar_url":"https://avatars.githubusercontent.com/u/5584520?v=3","gravatar_id":"","url":"https://api.github.com/users/HoangThiTuanDung","html_url":"https://github.com/HoangThiTuanDung","followers_url":"https://api.github.com/users/HoangThiTuanDung/followers","following_url":"https://api.github.com/users/HoangThiTuanDung/following{/other_user}","gists_url":"https://api.github.com/users/HoangThiTuanDung/gists{/gist_id}","starred_url":"https://api.github.com/users/HoangThiTuanDung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HoangThiTuanDung/subscriptions","organizations_url":"https://api.github.com/users/HoangThiTuanDung/orgs","repos_url":"https://api.github.com/users/HoangThiTuanDung/repos","events_url":"https://api.github.com/users/HoangThiTuanDung/events{/privacy}","received_events_url":"https://api.github.com/users/HoangThiTuanDung/received_events","type":"User","site_admin":false},"repo":{"id":33527445,"name":"fels_46","full_name":"HoangThiTuanDung/fels_46","owner":{"login":"HoangThiTuanDung","id":5584520,"avatar_url":"https://avatars.githubusercontent.com/u/5584520?v=3","gravatar_id":"","url":"https://api.github.com/users/HoangThiTuanDung","html_url":"https://github.com/HoangThiTuanDung","followers_url":"https://api.github.com/users/HoangThiTuanDung/followers","following_url":"https://api.github.com/users/HoangThiTuanDung/following{/other_user}","gists_url":"https://api.github.com/users/HoangThiTuanDung/gists{/gist_id}","starred_url":"https://api.github.com/users/HoangThiTuanDung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HoangThiTuanDung/subscriptions","organizations_url":"https://api.github.com/users/HoangThiTuanDung/orgs","repos_url":"https://api.github.com/users/HoangThiTuanDung/repos","events_url":"https://api.github.com/users/HoangThiTuanDung/events{/privacy}","received_events_url":"https://api.github.com/users/HoangThiTuanDung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/HoangThiTuanDung/fels_46","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/HoangThiTuanDung/fels_46","forks_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/forks","keys_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/teams","hooks_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/hooks","issue_events_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/issues/events{/number}","events_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/events","assignees_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/assignees{/user}","branches_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/branches{/branch}","tags_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/tags","blobs_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/git/refs{/sha}","trees_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/statuses/{sha}","languages_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/languages","stargazers_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/stargazers","contributors_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/contributors","subscribers_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/subscribers","subscription_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/subscription","commits_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/commits{/sha}","git_commits_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/git/commits{/sha}","comments_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/comments{/number}","issue_comment_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/issues/comments{/number}","contents_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/contents/{+path}","compare_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/merges","archive_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/downloads","issues_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/issues{/number}","pulls_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/pulls{/number}","milestones_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/milestones{/number}","notifications_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/labels{/name}","releases_url":"https://api.github.com/repos/HoangThiTuanDung/fels_46/releases{/id}","created_at":"2015-04-07T07:01:11Z","updated_at":"2015-02-04T11:29:05Z","pushed_at":"2015-04-15T03:34:01Z","git_url":"git://github.com/HoangThiTuanDung/fels_46.git","ssh_url":"git@github.com:HoangThiTuanDung/fels_46.git","clone_url":"https://github.com/HoangThiTuanDung/fels_46.git","svn_url":"https://github.com/HoangThiTuanDung/fels_46","homepage":null,"size":199,"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":"ba0f1d3d86cf7290d6c7ebd851feb41ef0360690","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":30295677,"name":"fels_46","full_name":"framgia/fels_46","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_46","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_46","forks_url":"https://api.github.com/repos/framgia/fels_46/forks","keys_url":"https://api.github.com/repos/framgia/fels_46/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_46/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_46/teams","hooks_url":"https://api.github.com/repos/framgia/fels_46/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_46/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_46/events","assignees_url":"https://api.github.com/repos/framgia/fels_46/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_46/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_46/tags","blobs_url":"https://api.github.com/repos/framgia/fels_46/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_46/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_46/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_46/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_46/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_46/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_46/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_46/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_46/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_46/subscription","commits_url":"https://api.github.com/repos/framgia/fels_46/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_46/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_46/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_46/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_46/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_46/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_46/merges","archive_url":"https://api.github.com/repos/framgia/fels_46/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_46/downloads","issues_url":"https://api.github.com/repos/framgia/fels_46/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_46/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_46/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_46/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_46/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_46/releases{/id}","created_at":"2015-02-04T11:29:05Z","updated_at":"2015-02-04T11:29:05Z","pushed_at":"2015-04-15T03:34:02Z","git_url":"git://github.com/framgia/fels_46.git","ssh_url":"git@github.com:framgia/fels_46.git","clone_url":"https://github.com/framgia/fels_46.git","svn_url":"https://github.com/framgia/fels_46","homepage":null,"size":1042,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_46/pulls/6"},"html":{"href":"https://github.com/framgia/fels_46/pull/6"},"issue":{"href":"https://api.github.com/repos/framgia/fels_46/issues/6"},"comments":{"href":"https://api.github.com/repos/framgia/fels_46/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_46/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_46/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_46/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_46/statuses/731df361af7c7eeb5efaacaf607cdfc1cbb36119"}}}}