{"action":"created","comment":{"url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/comments/61189659","id":61189659,"diff_hunk":"@@ -11,40 +21,25 @@ class Todo::Create < Trailblazer::Operation\n   #         associate `todo_list` with `user`\n   #         associate `todo` with `todo_list`\n   def process(params)\n-    # make sure title is not blank\n-    return invalid! if params[:todo][:title].blank?\n-\n-    # build the todo\n-    todo = @model = Todo.new(params.require(:todo).permit(:title, :description))\n-\n-    # find or create the parent list for the todo\n-    if params[:todo_list_id].blank?\n-      todo_list = TodoList.find_or_create_by(name: \"Default To-do List\")\n-\n-      # Find or create the owner of the todo_list:\n-      ##### If current_user_id is present, fetch that user\n-      ##### otherwise, create a new one\n-      current_user =\n-        if params[:current_user] == nil\n-          if params[:current_user_id] == nil\n-            User.create!(fullname: \"Guest\")\n-          else\n-            User.find(params[:current_user_id])\n-          end\n-        else\n-          params[:current_user]\n-        end\n-\n-      # assign the todo_list to the user\n-      todo_list.user = current_user\n-      todo_list.save!\n-    else # i.e. if params[:todo_list_id] is not nil\n-      todo_list = TodoList.find(params[:todo_list_id])\n+    # please try to debugger the output of validate(params[:todo]) here\n+    # it should be false if there is validation error, true otherwise\n+    validate(params[:todo]) do\n+      contract.save\n     end\n-\n-    # associate the todo with the todo_list\n-    todo.list = todo_list\n-    todo.save!\n   end\n \n-end\n+  private\n+\n+    def setup_model!(todo_params)\n+      # find or create the parent list for the todo\n+      if todo_params[:todo_list_id].present?# i.e. if params[:todo_list_id] is not nil\n+        todo_list = TodoList.find(todo_params[:todo_list_id])\n+      elsif TodoList.find_by_name(\"Default To-do List\").present?\n+        todo_list = TodoList.find_by_name(\"Default To-do List\")\n+      else\n+        result, operation = TodoList::Create.run(todo_list: { name: \"Default To-do List\" })\n+        todo_list = operation.model\n+      end\n+      model.list = todo_list\n+    end\n+end","path":"app/concepts/todo/create.rb","position":74,"original_position":74,"commit_id":"79e46ee028986523fb27ef6f9f21a20d81de3ae9","original_commit_id":"79e46ee028986523fb27ef6f9f21a20d81de3ae9","user":{"login":"kennethcalamay","id":347100,"avatar_url":"https://avatars.githubusercontent.com/u/347100?v=3","gravatar_id":"","url":"https://api.github.com/users/kennethcalamay","html_url":"https://github.com/kennethcalamay","followers_url":"https://api.github.com/users/kennethcalamay/followers","following_url":"https://api.github.com/users/kennethcalamay/following{/other_user}","gists_url":"https://api.github.com/users/kennethcalamay/gists{/gist_id}","starred_url":"https://api.github.com/users/kennethcalamay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennethcalamay/subscriptions","organizations_url":"https://api.github.com/users/kennethcalamay/orgs","repos_url":"https://api.github.com/users/kennethcalamay/repos","events_url":"https://api.github.com/users/kennethcalamay/events{/privacy}","received_events_url":"https://api.github.com/users/kennethcalamay/received_events","type":"User","site_admin":false},"body":"Looks good. We prefer descriptive names over comment and we want to avoid comments if we can. Can you get rid of the comments. It's nice that you're able to use `setup_model!` Looks like you really dug deep. Currently, this class knows about when to create a todo_list. Can we move that logic to inside TodoList?","created_at":"2016-04-27T00:59:09Z","updated_at":"2016-04-27T00:59:09Z","html_url":"https://github.com/serviceseeking/serviceseeking-test/pull/19#discussion_r61189659","pull_request_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/comments/61189659"},"html":{"href":"https://github.com/serviceseeking/serviceseeking-test/pull/19#discussion_r61189659"},"pull_request":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19","id":67746990,"html_url":"https://github.com/serviceseeking/serviceseeking-test/pull/19","diff_url":"https://github.com/serviceseeking/serviceseeking-test/pull/19.diff","patch_url":"https://github.com/serviceseeking/serviceseeking-test/pull/19.patch","issue_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues/19","number":19,"state":"open","locked":false,"title":"Initial commit for service-seeking coding challenge","user":{"login":"kdelrosario","id":8707515,"avatar_url":"https://avatars.githubusercontent.com/u/8707515?v=3","gravatar_id":"","url":"https://api.github.com/users/kdelrosario","html_url":"https://github.com/kdelrosario","followers_url":"https://api.github.com/users/kdelrosario/followers","following_url":"https://api.github.com/users/kdelrosario/following{/other_user}","gists_url":"https://api.github.com/users/kdelrosario/gists{/gist_id}","starred_url":"https://api.github.com/users/kdelrosario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdelrosario/subscriptions","organizations_url":"https://api.github.com/users/kdelrosario/orgs","repos_url":"https://api.github.com/users/kdelrosario/repos","events_url":"https://api.github.com/users/kdelrosario/events{/privacy}","received_events_url":"https://api.github.com/users/kdelrosario/received_events","type":"User","site_admin":false},"body":"- Refactor todo concept\r\n- Add todo-list trailblazer operation\r\n- Add styling to UI","created_at":"2016-04-25T16:15:12Z","updated_at":"2016-04-27T00:59:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19973e7eaaa2566a63e7b61b08979e28b9888f95","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19/commits","review_comments_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19/comments","review_comment_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/comments{/number}","comments_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues/19/comments","statuses_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/statuses/79e46ee028986523fb27ef6f9f21a20d81de3ae9","head":{"label":"kdelrosario:master","ref":"master","sha":"79e46ee028986523fb27ef6f9f21a20d81de3ae9","user":{"login":"kdelrosario","id":8707515,"avatar_url":"https://avatars.githubusercontent.com/u/8707515?v=3","gravatar_id":"","url":"https://api.github.com/users/kdelrosario","html_url":"https://github.com/kdelrosario","followers_url":"https://api.github.com/users/kdelrosario/followers","following_url":"https://api.github.com/users/kdelrosario/following{/other_user}","gists_url":"https://api.github.com/users/kdelrosario/gists{/gist_id}","starred_url":"https://api.github.com/users/kdelrosario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdelrosario/subscriptions","organizations_url":"https://api.github.com/users/kdelrosario/orgs","repos_url":"https://api.github.com/users/kdelrosario/repos","events_url":"https://api.github.com/users/kdelrosario/events{/privacy}","received_events_url":"https://api.github.com/users/kdelrosario/received_events","type":"User","site_admin":false},"repo":{"id":57055988,"name":"serviceseeking-test","full_name":"kdelrosario/serviceseeking-test","owner":{"login":"kdelrosario","id":8707515,"avatar_url":"https://avatars.githubusercontent.com/u/8707515?v=3","gravatar_id":"","url":"https://api.github.com/users/kdelrosario","html_url":"https://github.com/kdelrosario","followers_url":"https://api.github.com/users/kdelrosario/followers","following_url":"https://api.github.com/users/kdelrosario/following{/other_user}","gists_url":"https://api.github.com/users/kdelrosario/gists{/gist_id}","starred_url":"https://api.github.com/users/kdelrosario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdelrosario/subscriptions","organizations_url":"https://api.github.com/users/kdelrosario/orgs","repos_url":"https://api.github.com/users/kdelrosario/repos","events_url":"https://api.github.com/users/kdelrosario/events{/privacy}","received_events_url":"https://api.github.com/users/kdelrosario/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kdelrosario/serviceseeking-test","description":"","fork":true,"url":"https://api.github.com/repos/kdelrosario/serviceseeking-test","forks_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/forks","keys_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/teams","hooks_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/hooks","issue_events_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/issues/events{/number}","events_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/events","assignees_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/assignees{/user}","branches_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/branches{/branch}","tags_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/tags","blobs_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/statuses/{sha}","languages_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/languages","stargazers_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/stargazers","contributors_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/contributors","subscribers_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/subscribers","subscription_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/subscription","commits_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/contents/{+path}","compare_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/merges","archive_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/downloads","issues_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/issues{/number}","pulls_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/pulls{/number}","milestones_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/milestones{/number}","notifications_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/labels{/name}","releases_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/releases{/id}","deployments_url":"https://api.github.com/repos/kdelrosario/serviceseeking-test/deployments","created_at":"2016-04-25T16:02:39Z","updated_at":"2016-04-25T16:02:40Z","pushed_at":"2016-04-25T16:12:02Z","git_url":"git://github.com/kdelrosario/serviceseeking-test.git","ssh_url":"git@github.com:kdelrosario/serviceseeking-test.git","clone_url":"https://github.com/kdelrosario/serviceseeking-test.git","svn_url":"https://github.com/kdelrosario/serviceseeking-test","homepage":null,"size":56,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"serviceseeking:master","ref":"master","sha":"c783312123221cb4ee27f0121355aefd47bbcf4e","user":{"login":"serviceseeking","id":62600,"avatar_url":"https://avatars.githubusercontent.com/u/62600?v=3","gravatar_id":"","url":"https://api.github.com/users/serviceseeking","html_url":"https://github.com/serviceseeking","followers_url":"https://api.github.com/users/serviceseeking/followers","following_url":"https://api.github.com/users/serviceseeking/following{/other_user}","gists_url":"https://api.github.com/users/serviceseeking/gists{/gist_id}","starred_url":"https://api.github.com/users/serviceseeking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serviceseeking/subscriptions","organizations_url":"https://api.github.com/users/serviceseeking/orgs","repos_url":"https://api.github.com/users/serviceseeking/repos","events_url":"https://api.github.com/users/serviceseeking/events{/privacy}","received_events_url":"https://api.github.com/users/serviceseeking/received_events","type":"User","site_admin":false},"repo":{"id":46533634,"name":"serviceseeking-test","full_name":"serviceseeking/serviceseeking-test","owner":{"login":"serviceseeking","id":62600,"avatar_url":"https://avatars.githubusercontent.com/u/62600?v=3","gravatar_id":"","url":"https://api.github.com/users/serviceseeking","html_url":"https://github.com/serviceseeking","followers_url":"https://api.github.com/users/serviceseeking/followers","following_url":"https://api.github.com/users/serviceseeking/following{/other_user}","gists_url":"https://api.github.com/users/serviceseeking/gists{/gist_id}","starred_url":"https://api.github.com/users/serviceseeking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serviceseeking/subscriptions","organizations_url":"https://api.github.com/users/serviceseeking/orgs","repos_url":"https://api.github.com/users/serviceseeking/repos","events_url":"https://api.github.com/users/serviceseeking/events{/privacy}","received_events_url":"https://api.github.com/users/serviceseeking/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/serviceseeking/serviceseeking-test","description":"","fork":false,"url":"https://api.github.com/repos/serviceseeking/serviceseeking-test","forks_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/forks","keys_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/teams","hooks_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/hooks","issue_events_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues/events{/number}","events_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/events","assignees_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/assignees{/user}","branches_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/branches{/branch}","tags_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/tags","blobs_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/statuses/{sha}","languages_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/languages","stargazers_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/stargazers","contributors_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/contributors","subscribers_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/subscribers","subscription_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/subscription","commits_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/contents/{+path}","compare_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/merges","archive_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/downloads","issues_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues{/number}","pulls_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls{/number}","milestones_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/milestones{/number}","notifications_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/labels{/name}","releases_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/releases{/id}","deployments_url":"https://api.github.com/repos/serviceseeking/serviceseeking-test/deployments","created_at":"2015-11-20T02:24:27Z","updated_at":"2016-01-11T07:56:24Z","pushed_at":"2016-04-26T05:07:53Z","git_url":"git://github.com/serviceseeking/serviceseeking-test.git","ssh_url":"git@github.com:serviceseeking/serviceseeking-test.git","clone_url":"https://github.com/serviceseeking/serviceseeking-test.git","svn_url":"https://github.com/serviceseeking/serviceseeking-test","homepage":null,"size":66,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":3,"forks":14,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19"},"html":{"href":"https://github.com/serviceseeking/serviceseeking-test/pull/19"},"issue":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues/19"},"comments":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/serviceseeking/serviceseeking-test/statuses/79e46ee028986523fb27ef6f9f21a20d81de3ae9"}}}}