{"action":"created","comment":{"url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/comments/90835883","pull_request_review_id":11346891,"id":90835883,"diff_hunk":"@@ -1,7 +1,29 @@\n class Car < ApplicationRecord\n   belongs_to :train\n \n-  validates :car_type, presence: true \n-  validates :up_space, presence: true, numericality: { only_integer: true }\n-  validates :low_space, presence: true, numericality: { only_integer: true }\n+  validates :car_type, :number, presence: true\n+  validate :number_exist\n+\n+  scope :asc, -> { order(:number) }\n+  scope :desc, -> { order('number DESC') }\n+  scope :plazkart, -> { where(car_type: 'PlazkartCar') }\n+  scope :coupe, -> { where(car_type: 'CoupeCar') }\n+  scope :SV, -> { where(car_type: 'SVCar') }\n+  scope :seat, -> { where(car_type: 'SeatCar') }\n+\n+  before_validation :set_number\n+\n+  private\n+\n+  def set_number\n+    numb = Car.where(train_id: train).maximum(:number)\n+    self.number = numb == nil ? 1 : numb + 1","path":"app/models/car.rb","position":23,"original_position":23,"commit_id":"707915ddc1009f561cb2b1909edb40570d4cbcd0","original_commit_id":"707915ddc1009f561cb2b1909edb40570d4cbcd0","user":{"login":"vkurennov","id":968537,"avatar_url":"https://avatars.githubusercontent.com/u/968537?v=3","gravatar_id":"","url":"https://api.github.com/users/vkurennov","html_url":"https://github.com/vkurennov","followers_url":"https://api.github.com/users/vkurennov/followers","following_url":"https://api.github.com/users/vkurennov/following{/other_user}","gists_url":"https://api.github.com/users/vkurennov/gists{/gist_id}","starred_url":"https://api.github.com/users/vkurennov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkurennov/subscriptions","organizations_url":"https://api.github.com/users/vkurennov/orgs","repos_url":"https://api.github.com/users/vkurennov/repos","events_url":"https://api.github.com/users/vkurennov/events{/privacy}","received_events_url":"https://api.github.com/users/vkurennov/received_events","type":"User","site_admin":false},"body":"Не надо сравнивать с nil, он трактуется как false, значит можно написать так: `numb ? numb + 1 : 1`","created_at":"2016-12-05T10:20:37Z","updated_at":"2016-12-05T10:20:37Z","html_url":"https://github.com/BubuntuClu/trainsrep/pull/4#discussion_r90835883","pull_request_url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/comments/90835883"},"html":{"href":"https://github.com/BubuntuClu/trainsrep/pull/4#discussion_r90835883"},"pull_request":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4","id":96435150,"html_url":"https://github.com/BubuntuClu/trainsrep/pull/4","diff_url":"https://github.com/BubuntuClu/trainsrep/pull/4.diff","patch_url":"https://github.com/BubuntuClu/trainsrep/pull/4.patch","issue_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/4","number":4,"state":"open","locked":false,"title":"Activerecord","user":{"login":"BubuntuClu","id":13871063,"avatar_url":"https://avatars.githubusercontent.com/u/13871063?v=3","gravatar_id":"","url":"https://api.github.com/users/BubuntuClu","html_url":"https://github.com/BubuntuClu","followers_url":"https://api.github.com/users/BubuntuClu/followers","following_url":"https://api.github.com/users/BubuntuClu/following{/other_user}","gists_url":"https://api.github.com/users/BubuntuClu/gists{/gist_id}","starred_url":"https://api.github.com/users/BubuntuClu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BubuntuClu/subscriptions","organizations_url":"https://api.github.com/users/BubuntuClu/orgs","repos_url":"https://api.github.com/users/BubuntuClu/repos","events_url":"https://api.github.com/users/BubuntuClu/events{/privacy}","received_events_url":"https://api.github.com/users/BubuntuClu/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-04T15:04:33Z","updated_at":"2016-12-05T10:21:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c846fa86599521ed43f3c8245cc1005374dcd560","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4/commits","review_comments_url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4/comments","review_comment_url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/4/comments","statuses_url":"https://api.github.com/repos/BubuntuClu/trainsrep/statuses/707915ddc1009f561cb2b1909edb40570d4cbcd0","head":{"label":"BubuntuClu:activerecord","ref":"activerecord","sha":"707915ddc1009f561cb2b1909edb40570d4cbcd0","user":{"login":"BubuntuClu","id":13871063,"avatar_url":"https://avatars.githubusercontent.com/u/13871063?v=3","gravatar_id":"","url":"https://api.github.com/users/BubuntuClu","html_url":"https://github.com/BubuntuClu","followers_url":"https://api.github.com/users/BubuntuClu/followers","following_url":"https://api.github.com/users/BubuntuClu/following{/other_user}","gists_url":"https://api.github.com/users/BubuntuClu/gists{/gist_id}","starred_url":"https://api.github.com/users/BubuntuClu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BubuntuClu/subscriptions","organizations_url":"https://api.github.com/users/BubuntuClu/orgs","repos_url":"https://api.github.com/users/BubuntuClu/repos","events_url":"https://api.github.com/users/BubuntuClu/events{/privacy}","received_events_url":"https://api.github.com/users/BubuntuClu/received_events","type":"User","site_admin":false},"repo":{"id":75000058,"name":"trainsrep","full_name":"BubuntuClu/trainsrep","owner":{"login":"BubuntuClu","id":13871063,"avatar_url":"https://avatars.githubusercontent.com/u/13871063?v=3","gravatar_id":"","url":"https://api.github.com/users/BubuntuClu","html_url":"https://github.com/BubuntuClu","followers_url":"https://api.github.com/users/BubuntuClu/followers","following_url":"https://api.github.com/users/BubuntuClu/following{/other_user}","gists_url":"https://api.github.com/users/BubuntuClu/gists{/gist_id}","starred_url":"https://api.github.com/users/BubuntuClu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BubuntuClu/subscriptions","organizations_url":"https://api.github.com/users/BubuntuClu/orgs","repos_url":"https://api.github.com/users/BubuntuClu/repos","events_url":"https://api.github.com/users/BubuntuClu/events{/privacy}","received_events_url":"https://api.github.com/users/BubuntuClu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BubuntuClu/trainsrep","description":null,"fork":false,"url":"https://api.github.com/repos/BubuntuClu/trainsrep","forks_url":"https://api.github.com/repos/BubuntuClu/trainsrep/forks","keys_url":"https://api.github.com/repos/BubuntuClu/trainsrep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BubuntuClu/trainsrep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BubuntuClu/trainsrep/teams","hooks_url":"https://api.github.com/repos/BubuntuClu/trainsrep/hooks","issue_events_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/events{/number}","events_url":"https://api.github.com/repos/BubuntuClu/trainsrep/events","assignees_url":"https://api.github.com/repos/BubuntuClu/trainsrep/assignees{/user}","branches_url":"https://api.github.com/repos/BubuntuClu/trainsrep/branches{/branch}","tags_url":"https://api.github.com/repos/BubuntuClu/trainsrep/tags","blobs_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/refs{/sha}","trees_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BubuntuClu/trainsrep/statuses/{sha}","languages_url":"https://api.github.com/repos/BubuntuClu/trainsrep/languages","stargazers_url":"https://api.github.com/repos/BubuntuClu/trainsrep/stargazers","contributors_url":"https://api.github.com/repos/BubuntuClu/trainsrep/contributors","subscribers_url":"https://api.github.com/repos/BubuntuClu/trainsrep/subscribers","subscription_url":"https://api.github.com/repos/BubuntuClu/trainsrep/subscription","commits_url":"https://api.github.com/repos/BubuntuClu/trainsrep/commits{/sha}","git_commits_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/commits{/sha}","comments_url":"https://api.github.com/repos/BubuntuClu/trainsrep/comments{/number}","issue_comment_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/comments{/number}","contents_url":"https://api.github.com/repos/BubuntuClu/trainsrep/contents/{+path}","compare_url":"https://api.github.com/repos/BubuntuClu/trainsrep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BubuntuClu/trainsrep/merges","archive_url":"https://api.github.com/repos/BubuntuClu/trainsrep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BubuntuClu/trainsrep/downloads","issues_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues{/number}","pulls_url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls{/number}","milestones_url":"https://api.github.com/repos/BubuntuClu/trainsrep/milestones{/number}","notifications_url":"https://api.github.com/repos/BubuntuClu/trainsrep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BubuntuClu/trainsrep/labels{/name}","releases_url":"https://api.github.com/repos/BubuntuClu/trainsrep/releases{/id}","deployments_url":"https://api.github.com/repos/BubuntuClu/trainsrep/deployments","created_at":"2016-11-28T18:04:43Z","updated_at":"2016-11-28T19:39:16Z","pushed_at":"2016-12-04T15:04:33Z","git_url":"git://github.com/BubuntuClu/trainsrep.git","ssh_url":"git@github.com:BubuntuClu/trainsrep.git","clone_url":"https://github.com/BubuntuClu/trainsrep.git","svn_url":"https://github.com/BubuntuClu/trainsrep","homepage":null,"size":938,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"BubuntuClu:master","ref":"master","sha":"f10f9f222d98e945c981ba33787e86f7bdad3c41","user":{"login":"BubuntuClu","id":13871063,"avatar_url":"https://avatars.githubusercontent.com/u/13871063?v=3","gravatar_id":"","url":"https://api.github.com/users/BubuntuClu","html_url":"https://github.com/BubuntuClu","followers_url":"https://api.github.com/users/BubuntuClu/followers","following_url":"https://api.github.com/users/BubuntuClu/following{/other_user}","gists_url":"https://api.github.com/users/BubuntuClu/gists{/gist_id}","starred_url":"https://api.github.com/users/BubuntuClu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BubuntuClu/subscriptions","organizations_url":"https://api.github.com/users/BubuntuClu/orgs","repos_url":"https://api.github.com/users/BubuntuClu/repos","events_url":"https://api.github.com/users/BubuntuClu/events{/privacy}","received_events_url":"https://api.github.com/users/BubuntuClu/received_events","type":"User","site_admin":false},"repo":{"id":75000058,"name":"trainsrep","full_name":"BubuntuClu/trainsrep","owner":{"login":"BubuntuClu","id":13871063,"avatar_url":"https://avatars.githubusercontent.com/u/13871063?v=3","gravatar_id":"","url":"https://api.github.com/users/BubuntuClu","html_url":"https://github.com/BubuntuClu","followers_url":"https://api.github.com/users/BubuntuClu/followers","following_url":"https://api.github.com/users/BubuntuClu/following{/other_user}","gists_url":"https://api.github.com/users/BubuntuClu/gists{/gist_id}","starred_url":"https://api.github.com/users/BubuntuClu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BubuntuClu/subscriptions","organizations_url":"https://api.github.com/users/BubuntuClu/orgs","repos_url":"https://api.github.com/users/BubuntuClu/repos","events_url":"https://api.github.com/users/BubuntuClu/events{/privacy}","received_events_url":"https://api.github.com/users/BubuntuClu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BubuntuClu/trainsrep","description":null,"fork":false,"url":"https://api.github.com/repos/BubuntuClu/trainsrep","forks_url":"https://api.github.com/repos/BubuntuClu/trainsrep/forks","keys_url":"https://api.github.com/repos/BubuntuClu/trainsrep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BubuntuClu/trainsrep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BubuntuClu/trainsrep/teams","hooks_url":"https://api.github.com/repos/BubuntuClu/trainsrep/hooks","issue_events_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/events{/number}","events_url":"https://api.github.com/repos/BubuntuClu/trainsrep/events","assignees_url":"https://api.github.com/repos/BubuntuClu/trainsrep/assignees{/user}","branches_url":"https://api.github.com/repos/BubuntuClu/trainsrep/branches{/branch}","tags_url":"https://api.github.com/repos/BubuntuClu/trainsrep/tags","blobs_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/refs{/sha}","trees_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BubuntuClu/trainsrep/statuses/{sha}","languages_url":"https://api.github.com/repos/BubuntuClu/trainsrep/languages","stargazers_url":"https://api.github.com/repos/BubuntuClu/trainsrep/stargazers","contributors_url":"https://api.github.com/repos/BubuntuClu/trainsrep/contributors","subscribers_url":"https://api.github.com/repos/BubuntuClu/trainsrep/subscribers","subscription_url":"https://api.github.com/repos/BubuntuClu/trainsrep/subscription","commits_url":"https://api.github.com/repos/BubuntuClu/trainsrep/commits{/sha}","git_commits_url":"https://api.github.com/repos/BubuntuClu/trainsrep/git/commits{/sha}","comments_url":"https://api.github.com/repos/BubuntuClu/trainsrep/comments{/number}","issue_comment_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/comments{/number}","contents_url":"https://api.github.com/repos/BubuntuClu/trainsrep/contents/{+path}","compare_url":"https://api.github.com/repos/BubuntuClu/trainsrep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BubuntuClu/trainsrep/merges","archive_url":"https://api.github.com/repos/BubuntuClu/trainsrep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BubuntuClu/trainsrep/downloads","issues_url":"https://api.github.com/repos/BubuntuClu/trainsrep/issues{/number}","pulls_url":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls{/number}","milestones_url":"https://api.github.com/repos/BubuntuClu/trainsrep/milestones{/number}","notifications_url":"https://api.github.com/repos/BubuntuClu/trainsrep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BubuntuClu/trainsrep/labels{/name}","releases_url":"https://api.github.com/repos/BubuntuClu/trainsrep/releases{/id}","deployments_url":"https://api.github.com/repos/BubuntuClu/trainsrep/deployments","created_at":"2016-11-28T18:04:43Z","updated_at":"2016-11-28T19:39:16Z","pushed_at":"2016-12-04T15:04:33Z","git_url":"git://github.com/BubuntuClu/trainsrep.git","ssh_url":"git@github.com:BubuntuClu/trainsrep.git","clone_url":"https://github.com/BubuntuClu/trainsrep.git","svn_url":"https://github.com/BubuntuClu/trainsrep","homepage":null,"size":938,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4"},"html":{"href":"https://github.com/BubuntuClu/trainsrep/pull/4"},"issue":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/4"},"comments":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/BubuntuClu/trainsrep/statuses/707915ddc1009f561cb2b1909edb40570d4cbcd0"}}}}
{"actor":{"display_login":"vkurennov"}}