{"action":"created","comment":{"url":"https://api.github.com/repos/openSUSE/open-build-service/pulls/comments/84649609","pull_request_review_id":5412892,"id":84649609,"diff_hunk":"@@ -75,4 +79,10 @@ def blank_or_destroy\n   def destroy\n     super\n   end\n+\n+  private\n+\n+  def check_is_child\n+    errors[:type] << \"is reserved for storing the inheritance class which was not found\" unless type.safe_constantize.try(:superclass) == Comment","path":"src/api/app/models/comment.rb","position":19,"original_position":19,"commit_id":"a35768e486dadef3e5f39e33b62113762162f403","original_commit_id":"051431f21cddbd9896228bca950ef9a2b3fa6094","user":{"login":"Ana06","id":16052290,"avatar_url":"https://avatars.githubusercontent.com/u/16052290?v=3","gravatar_id":"","url":"https://api.github.com/users/Ana06","html_url":"https://github.com/Ana06","followers_url":"https://api.github.com/users/Ana06/followers","following_url":"https://api.github.com/users/Ana06/following{/other_user}","gists_url":"https://api.github.com/users/Ana06/gists{/gist_id}","starred_url":"https://api.github.com/users/Ana06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ana06/subscriptions","organizations_url":"https://api.github.com/users/Ana06/orgs","repos_url":"https://api.github.com/users/Ana06/repos","events_url":"https://api.github.com/users/Ana06/events{/privacy}","received_events_url":"https://api.github.com/users/Ana06/received_events","type":"User","site_admin":false},"body":"ok! :+1: ","created_at":"2016-10-24T09:27:50Z","updated_at":"2016-10-24T09:27:50Z","html_url":"https://github.com/openSUSE/open-build-service/pull/2252#discussion_r84649609","pull_request_url":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252","_links":{"self":{"href":"https://api.github.com/repos/openSUSE/open-build-service/pulls/comments/84649609"},"html":{"href":"https://github.com/openSUSE/open-build-service/pull/2252#discussion_r84649609"},"pull_request":{"href":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252"}}},"pull_request":{"url":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252","id":90409285,"html_url":"https://github.com/openSUSE/open-build-service/pull/2252","diff_url":"https://github.com/openSUSE/open-build-service/pull/2252.diff","patch_url":"https://github.com/openSUSE/open-build-service/pull/2252.patch","issue_url":"https://api.github.com/repos/openSUSE/open-build-service/issues/2252","number":2252,"state":"open","locked":false,"title":"[api][webui] Add validation for Comment type","user":{"login":"Ana06","id":16052290,"avatar_url":"https://avatars.githubusercontent.com/u/16052290?v=3","gravatar_id":"","url":"https://api.github.com/users/Ana06","html_url":"https://github.com/Ana06","followers_url":"https://api.github.com/users/Ana06/followers","following_url":"https://api.github.com/users/Ana06/following{/other_user}","gists_url":"https://api.github.com/users/Ana06/gists{/gist_id}","starred_url":"https://api.github.com/users/Ana06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ana06/subscriptions","organizations_url":"https://api.github.com/users/Ana06/orgs","repos_url":"https://api.github.com/users/Ana06/repos","events_url":"https://api.github.com/users/Ana06/events{/privacy}","received_events_url":"https://api.github.com/users/Ana06/received_events","type":"User","site_admin":false},"body":"The column `type` of `Comment` is reserved for storing the the class in case of inheritance and it is `nil` otherwise. As we validate that it is present it can not be `nil`. So that means that it is not possible to create a `Comment `directly, only instances of `Comment` children can be created. In case that we try to create an` Comment` with a non `nil` type which is not a name of any of the `Comment `children the following error is raised in the database level:\r\n\r\n`ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'foo'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Parent.inheritance_column to use another column for that information.`\r\n\r\nIt is not obvious that an instance of `Comment` can not be directly created and that the type is used for the single table inheritance, so the comment and the validation make it much more clear.\r\n\r\nIt is also a good idea to check it in a Rails validation because for example it won't fail in factories, like happens in https://github.com/openSUSE/open-build-service/pull/2247 where a factory for `comment` is created with a random word as type, which would raise an exception in Rails but works perfectly in a factory.","created_at":"2016-10-21T15:56:48Z","updated_at":"2016-10-24T09:27:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3221ac2d060858706522b19f9c5a0e3b9464c49","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252/commits","review_comments_url":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252/comments","review_comment_url":"https://api.github.com/repos/openSUSE/open-build-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openSUSE/open-build-service/issues/2252/comments","statuses_url":"https://api.github.com/repos/openSUSE/open-build-service/statuses/a35768e486dadef3e5f39e33b62113762162f403","head":{"label":"Ana06:abstract_class","ref":"abstract_class","sha":"a35768e486dadef3e5f39e33b62113762162f403","user":{"login":"Ana06","id":16052290,"avatar_url":"https://avatars.githubusercontent.com/u/16052290?v=3","gravatar_id":"","url":"https://api.github.com/users/Ana06","html_url":"https://github.com/Ana06","followers_url":"https://api.github.com/users/Ana06/followers","following_url":"https://api.github.com/users/Ana06/following{/other_user}","gists_url":"https://api.github.com/users/Ana06/gists{/gist_id}","starred_url":"https://api.github.com/users/Ana06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ana06/subscriptions","organizations_url":"https://api.github.com/users/Ana06/orgs","repos_url":"https://api.github.com/users/Ana06/repos","events_url":"https://api.github.com/users/Ana06/events{/privacy}","received_events_url":"https://api.github.com/users/Ana06/received_events","type":"User","site_admin":false},"repo":{"id":67222232,"name":"open-build-service","full_name":"Ana06/open-build-service","owner":{"login":"Ana06","id":16052290,"avatar_url":"https://avatars.githubusercontent.com/u/16052290?v=3","gravatar_id":"","url":"https://api.github.com/users/Ana06","html_url":"https://github.com/Ana06","followers_url":"https://api.github.com/users/Ana06/followers","following_url":"https://api.github.com/users/Ana06/following{/other_user}","gists_url":"https://api.github.com/users/Ana06/gists{/gist_id}","starred_url":"https://api.github.com/users/Ana06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ana06/subscriptions","organizations_url":"https://api.github.com/users/Ana06/orgs","repos_url":"https://api.github.com/users/Ana06/repos","events_url":"https://api.github.com/users/Ana06/events{/privacy}","received_events_url":"https://api.github.com/users/Ana06/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ana06/open-build-service","description":"A generic system to build and distribute packages from sources in an automatic, consistent and reproducible way. Release your software for a wide range of operating systems and hardware architectures.","fork":true,"url":"https://api.github.com/repos/Ana06/open-build-service","forks_url":"https://api.github.com/repos/Ana06/open-build-service/forks","keys_url":"https://api.github.com/repos/Ana06/open-build-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ana06/open-build-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ana06/open-build-service/teams","hooks_url":"https://api.github.com/repos/Ana06/open-build-service/hooks","issue_events_url":"https://api.github.com/repos/Ana06/open-build-service/issues/events{/number}","events_url":"https://api.github.com/repos/Ana06/open-build-service/events","assignees_url":"https://api.github.com/repos/Ana06/open-build-service/assignees{/user}","branches_url":"https://api.github.com/repos/Ana06/open-build-service/branches{/branch}","tags_url":"https://api.github.com/repos/Ana06/open-build-service/tags","blobs_url":"https://api.github.com/repos/Ana06/open-build-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ana06/open-build-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ana06/open-build-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ana06/open-build-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ana06/open-build-service/statuses/{sha}","languages_url":"https://api.github.com/repos/Ana06/open-build-service/languages","stargazers_url":"https://api.github.com/repos/Ana06/open-build-service/stargazers","contributors_url":"https://api.github.com/repos/Ana06/open-build-service/contributors","subscribers_url":"https://api.github.com/repos/Ana06/open-build-service/subscribers","subscription_url":"https://api.github.com/repos/Ana06/open-build-service/subscription","commits_url":"https://api.github.com/repos/Ana06/open-build-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ana06/open-build-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ana06/open-build-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ana06/open-build-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ana06/open-build-service/contents/{+path}","compare_url":"https://api.github.com/repos/Ana06/open-build-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ana06/open-build-service/merges","archive_url":"https://api.github.com/repos/Ana06/open-build-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ana06/open-build-service/downloads","issues_url":"https://api.github.com/repos/Ana06/open-build-service/issues{/number}","pulls_url":"https://api.github.com/repos/Ana06/open-build-service/pulls{/number}","milestones_url":"https://api.github.com/repos/Ana06/open-build-service/milestones{/number}","notifications_url":"https://api.github.com/repos/Ana06/open-build-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ana06/open-build-service/labels{/name}","releases_url":"https://api.github.com/repos/Ana06/open-build-service/releases{/id}","deployments_url":"https://api.github.com/repos/Ana06/open-build-service/deployments","created_at":"2016-09-02T12:51:10Z","updated_at":"2016-10-24T07:34:41Z","pushed_at":"2016-10-24T07:34:39Z","git_url":"git://github.com/Ana06/open-build-service.git","ssh_url":"git@github.com:Ana06/open-build-service.git","clone_url":"https://github.com/Ana06/open-build-service.git","svn_url":"https://github.com/Ana06/open-build-service","homepage":"http://openbuildservice.org/","size":45668,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"openSUSE:master","ref":"master","sha":"60609c26cc5949d7108612b61862b9ba3e226a90","user":{"login":"openSUSE","id":623819,"avatar_url":"https://avatars.githubusercontent.com/u/623819?v=3","gravatar_id":"","url":"https://api.github.com/users/openSUSE","html_url":"https://github.com/openSUSE","followers_url":"https://api.github.com/users/openSUSE/followers","following_url":"https://api.github.com/users/openSUSE/following{/other_user}","gists_url":"https://api.github.com/users/openSUSE/gists{/gist_id}","starred_url":"https://api.github.com/users/openSUSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openSUSE/subscriptions","organizations_url":"https://api.github.com/users/openSUSE/orgs","repos_url":"https://api.github.com/users/openSUSE/repos","events_url":"https://api.github.com/users/openSUSE/events{/privacy}","received_events_url":"https://api.github.com/users/openSUSE/received_events","type":"Organization","site_admin":false},"repo":{"id":2046192,"name":"open-build-service","full_name":"openSUSE/open-build-service","owner":{"login":"openSUSE","id":623819,"avatar_url":"https://avatars.githubusercontent.com/u/623819?v=3","gravatar_id":"","url":"https://api.github.com/users/openSUSE","html_url":"https://github.com/openSUSE","followers_url":"https://api.github.com/users/openSUSE/followers","following_url":"https://api.github.com/users/openSUSE/following{/other_user}","gists_url":"https://api.github.com/users/openSUSE/gists{/gist_id}","starred_url":"https://api.github.com/users/openSUSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openSUSE/subscriptions","organizations_url":"https://api.github.com/users/openSUSE/orgs","repos_url":"https://api.github.com/users/openSUSE/repos","events_url":"https://api.github.com/users/openSUSE/events{/privacy}","received_events_url":"https://api.github.com/users/openSUSE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openSUSE/open-build-service","description":"A generic system to build and distribute packages from sources in an automatic, consistent and reproducible way. Release your software for a wide range of operating systems and hardware architectures.","fork":false,"url":"https://api.github.com/repos/openSUSE/open-build-service","forks_url":"https://api.github.com/repos/openSUSE/open-build-service/forks","keys_url":"https://api.github.com/repos/openSUSE/open-build-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openSUSE/open-build-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openSUSE/open-build-service/teams","hooks_url":"https://api.github.com/repos/openSUSE/open-build-service/hooks","issue_events_url":"https://api.github.com/repos/openSUSE/open-build-service/issues/events{/number}","events_url":"https://api.github.com/repos/openSUSE/open-build-service/events","assignees_url":"https://api.github.com/repos/openSUSE/open-build-service/assignees{/user}","branches_url":"https://api.github.com/repos/openSUSE/open-build-service/branches{/branch}","tags_url":"https://api.github.com/repos/openSUSE/open-build-service/tags","blobs_url":"https://api.github.com/repos/openSUSE/open-build-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openSUSE/open-build-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openSUSE/open-build-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/openSUSE/open-build-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openSUSE/open-build-service/statuses/{sha}","languages_url":"https://api.github.com/repos/openSUSE/open-build-service/languages","stargazers_url":"https://api.github.com/repos/openSUSE/open-build-service/stargazers","contributors_url":"https://api.github.com/repos/openSUSE/open-build-service/contributors","subscribers_url":"https://api.github.com/repos/openSUSE/open-build-service/subscribers","subscription_url":"https://api.github.com/repos/openSUSE/open-build-service/subscription","commits_url":"https://api.github.com/repos/openSUSE/open-build-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/openSUSE/open-build-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/openSUSE/open-build-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/openSUSE/open-build-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/openSUSE/open-build-service/contents/{+path}","compare_url":"https://api.github.com/repos/openSUSE/open-build-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openSUSE/open-build-service/merges","archive_url":"https://api.github.com/repos/openSUSE/open-build-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openSUSE/open-build-service/downloads","issues_url":"https://api.github.com/repos/openSUSE/open-build-service/issues{/number}","pulls_url":"https://api.github.com/repos/openSUSE/open-build-service/pulls{/number}","milestones_url":"https://api.github.com/repos/openSUSE/open-build-service/milestones{/number}","notifications_url":"https://api.github.com/repos/openSUSE/open-build-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openSUSE/open-build-service/labels{/name}","releases_url":"https://api.github.com/repos/openSUSE/open-build-service/releases{/id}","deployments_url":"https://api.github.com/repos/openSUSE/open-build-service/deployments","created_at":"2011-07-14T06:52:57Z","updated_at":"2016-10-24T09:15:48Z","pushed_at":"2016-10-24T09:15:46Z","git_url":"git://github.com/openSUSE/open-build-service.git","ssh_url":"git@github.com:openSUSE/open-build-service.git","clone_url":"https://github.com/openSUSE/open-build-service.git","svn_url":"https://github.com/openSUSE/open-build-service","homepage":"http://openbuildservice.org/","size":55024,"stargazers_count":227,"watchers_count":227,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":172,"mirror_url":null,"open_issues_count":300,"forks":172,"open_issues":300,"watchers":227,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252"},"html":{"href":"https://github.com/openSUSE/open-build-service/pull/2252"},"issue":{"href":"https://api.github.com/repos/openSUSE/open-build-service/issues/2252"},"comments":{"href":"https://api.github.com/repos/openSUSE/open-build-service/issues/2252/comments"},"review_comments":{"href":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252/comments"},"review_comment":{"href":"https://api.github.com/repos/openSUSE/open-build-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openSUSE/open-build-service/pulls/2252/commits"},"statuses":{"href":"https://api.github.com/repos/openSUSE/open-build-service/statuses/a35768e486dadef3e5f39e33b62113762162f403"}}}}
{"actor":{"display_login":"Ana06"}}