{"action":"created","comment":{"url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/comments/49367494","id":49367494,"diff_hunk":"@@ -1,7 +1,25 @@\n-# This file should contain all the record creation needed to seed the database with its default values.\n-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).\n-#\n-# Examples:\n-#\n-#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])\n-#   Mayor.create(name: 'Emanuel', city: cities.first)\n+# Popula o banco com estados e cidades brasileiras\n+\n+require 'net/http'\n+require 'net/https' # for ruby 1.8.7\n+require 'json'\n+\n+# Busca informações de um json com as informações\n+def states\n+  http = Net::HTTP.new('raw.githubusercontent.com', 443); http.use_ssl = true\n+  JSON.parse http.get('/zigotto/br_populate/master/states.json').body\n+end\n+\n+# Confere se a cidade é uma capital\n+def capital?(city, state)\n+  city == state[\"capital\"]\n+end\n+\n+# Grava as informações no banco\n+ActiveRecord::Base.transaction do\n+  states.each do |state|\n+    state_obj = State.find_or_create_by(acronym: state[\"acronym\"], name: state[\"name\"])\n+\n+    state[\"cities\"].map { |city| City.find_or_create_by(name: city, state: state_obj, capital: capital?(city, state)) }","path":"db/seeds.rb","position":30,"original_position":30,"commit_id":"3451e9d6e3c2dd74982d915b3b834d914681eb14","original_commit_id":"3451e9d6e3c2dd74982d915b3b834d914681eb14","user":{"login":"dodops","id":706049,"avatar_url":"https://avatars.githubusercontent.com/u/706049?v=3","gravatar_id":"","url":"https://api.github.com/users/dodops","html_url":"https://github.com/dodops","followers_url":"https://api.github.com/users/dodops/followers","following_url":"https://api.github.com/users/dodops/following{/other_user}","gists_url":"https://api.github.com/users/dodops/gists{/gist_id}","starred_url":"https://api.github.com/users/dodops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dodops/subscriptions","organizations_url":"https://api.github.com/users/dodops/orgs","repos_url":"https://api.github.com/users/dodops/repos","events_url":"https://api.github.com/users/dodops/events{/privacy}","received_events_url":"https://api.github.com/users/dodops/received_events","type":"User","site_admin":false},"body":"Ok, não conhecia a gem. Estou revisando.","created_at":"2016-01-11T19:39:37Z","updated_at":"2016-01-11T19:39:37Z","html_url":"https://github.com/pnaponoceno/learning-ruby/pull/50#discussion_r49367494","pull_request_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/comments/49367494"},"html":{"href":"https://github.com/pnaponoceno/learning-ruby/pull/50#discussion_r49367494"},"pull_request":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50","id":55647367,"html_url":"https://github.com/pnaponoceno/learning-ruby/pull/50","diff_url":"https://github.com/pnaponoceno/learning-ruby/pull/50.diff","patch_url":"https://github.com/pnaponoceno/learning-ruby/pull/50.patch","issue_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues/50","number":50,"state":"open","locked":false,"title":"Address, City and State models.","user":{"login":"dodops","id":706049,"avatar_url":"https://avatars.githubusercontent.com/u/706049?v=3","gravatar_id":"","url":"https://api.github.com/users/dodops","html_url":"https://github.com/dodops","followers_url":"https://api.github.com/users/dodops/followers","following_url":"https://api.github.com/users/dodops/following{/other_user}","gists_url":"https://api.github.com/users/dodops/gists{/gist_id}","starred_url":"https://api.github.com/users/dodops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dodops/subscriptions","organizations_url":"https://api.github.com/users/dodops/orgs","repos_url":"https://api.github.com/users/dodops/repos","events_url":"https://api.github.com/users/dodops/events{/privacy}","received_events_url":"https://api.github.com/users/dodops/received_events","type":"User","site_admin":false},"body":"Olá pessoas.\r\n\r\nEntão, fiz algumas modificações na estrutura dos relacionamentos que considero mais apropriado, com `address` sendo um modulo polimórfico e fazendo sua relação com o usuário. Estado e cidade são relacionados entre si.\r\n\r\nAlgo com #46 #47 #48 \r\n\r\nO testes estão bem blá, mas dá pra melhorar.\r\n\r\nContribuição especial do @dfmoreto e da galera do hangout. Vcs são f* :+1: :smile: :stuck_out_tongue_closed_eyes: ","created_at":"2016-01-11T16:53:00Z","updated_at":"2016-01-11T19:39:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e3c58a66fb692134cdff0233c384b36c543ff2ba","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50/commits","review_comments_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50/comments","review_comment_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues/50/comments","statuses_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/statuses/3451e9d6e3c2dd74982d915b3b834d914681eb14","head":{"label":"dodops:address","ref":"address","sha":"3451e9d6e3c2dd74982d915b3b834d914681eb14","user":{"login":"dodops","id":706049,"avatar_url":"https://avatars.githubusercontent.com/u/706049?v=3","gravatar_id":"","url":"https://api.github.com/users/dodops","html_url":"https://github.com/dodops","followers_url":"https://api.github.com/users/dodops/followers","following_url":"https://api.github.com/users/dodops/following{/other_user}","gists_url":"https://api.github.com/users/dodops/gists{/gist_id}","starred_url":"https://api.github.com/users/dodops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dodops/subscriptions","organizations_url":"https://api.github.com/users/dodops/orgs","repos_url":"https://api.github.com/users/dodops/repos","events_url":"https://api.github.com/users/dodops/events{/privacy}","received_events_url":"https://api.github.com/users/dodops/received_events","type":"User","site_admin":false},"repo":{"id":48893197,"name":"learning-ruby","full_name":"dodops/learning-ruby","owner":{"login":"dodops","id":706049,"avatar_url":"https://avatars.githubusercontent.com/u/706049?v=3","gravatar_id":"","url":"https://api.github.com/users/dodops","html_url":"https://github.com/dodops","followers_url":"https://api.github.com/users/dodops/followers","following_url":"https://api.github.com/users/dodops/following{/other_user}","gists_url":"https://api.github.com/users/dodops/gists{/gist_id}","starred_url":"https://api.github.com/users/dodops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dodops/subscriptions","organizations_url":"https://api.github.com/users/dodops/orgs","repos_url":"https://api.github.com/users/dodops/repos","events_url":"https://api.github.com/users/dodops/events{/privacy}","received_events_url":"https://api.github.com/users/dodops/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dodops/learning-ruby","description":"Git para estudos de Ruby","fork":true,"url":"https://api.github.com/repos/dodops/learning-ruby","forks_url":"https://api.github.com/repos/dodops/learning-ruby/forks","keys_url":"https://api.github.com/repos/dodops/learning-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dodops/learning-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dodops/learning-ruby/teams","hooks_url":"https://api.github.com/repos/dodops/learning-ruby/hooks","issue_events_url":"https://api.github.com/repos/dodops/learning-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/dodops/learning-ruby/events","assignees_url":"https://api.github.com/repos/dodops/learning-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/dodops/learning-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/dodops/learning-ruby/tags","blobs_url":"https://api.github.com/repos/dodops/learning-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dodops/learning-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dodops/learning-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/dodops/learning-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dodops/learning-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/dodops/learning-ruby/languages","stargazers_url":"https://api.github.com/repos/dodops/learning-ruby/stargazers","contributors_url":"https://api.github.com/repos/dodops/learning-ruby/contributors","subscribers_url":"https://api.github.com/repos/dodops/learning-ruby/subscribers","subscription_url":"https://api.github.com/repos/dodops/learning-ruby/subscription","commits_url":"https://api.github.com/repos/dodops/learning-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/dodops/learning-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/dodops/learning-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/dodops/learning-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/dodops/learning-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/dodops/learning-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dodops/learning-ruby/merges","archive_url":"https://api.github.com/repos/dodops/learning-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dodops/learning-ruby/downloads","issues_url":"https://api.github.com/repos/dodops/learning-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/dodops/learning-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/dodops/learning-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/dodops/learning-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dodops/learning-ruby/labels{/name}","releases_url":"https://api.github.com/repos/dodops/learning-ruby/releases{/id}","created_at":"2016-01-01T23:57:03Z","updated_at":"2016-01-01T23:57:04Z","pushed_at":"2016-01-11T18:09:25Z","git_url":"git://github.com/dodops/learning-ruby.git","ssh_url":"git@github.com:dodops/learning-ruby.git","clone_url":"https://github.com/dodops/learning-ruby.git","svn_url":"https://github.com/dodops/learning-ruby","homepage":null,"size":79,"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":"pnaponoceno:master","ref":"master","sha":"73920cccfb09c0676462a634b9d923c09c92137e","user":{"login":"pnaponoceno","id":8226585,"avatar_url":"https://avatars.githubusercontent.com/u/8226585?v=3","gravatar_id":"","url":"https://api.github.com/users/pnaponoceno","html_url":"https://github.com/pnaponoceno","followers_url":"https://api.github.com/users/pnaponoceno/followers","following_url":"https://api.github.com/users/pnaponoceno/following{/other_user}","gists_url":"https://api.github.com/users/pnaponoceno/gists{/gist_id}","starred_url":"https://api.github.com/users/pnaponoceno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnaponoceno/subscriptions","organizations_url":"https://api.github.com/users/pnaponoceno/orgs","repos_url":"https://api.github.com/users/pnaponoceno/repos","events_url":"https://api.github.com/users/pnaponoceno/events{/privacy}","received_events_url":"https://api.github.com/users/pnaponoceno/received_events","type":"User","site_admin":false},"repo":{"id":48884608,"name":"learning-ruby","full_name":"pnaponoceno/learning-ruby","owner":{"login":"pnaponoceno","id":8226585,"avatar_url":"https://avatars.githubusercontent.com/u/8226585?v=3","gravatar_id":"","url":"https://api.github.com/users/pnaponoceno","html_url":"https://github.com/pnaponoceno","followers_url":"https://api.github.com/users/pnaponoceno/followers","following_url":"https://api.github.com/users/pnaponoceno/following{/other_user}","gists_url":"https://api.github.com/users/pnaponoceno/gists{/gist_id}","starred_url":"https://api.github.com/users/pnaponoceno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnaponoceno/subscriptions","organizations_url":"https://api.github.com/users/pnaponoceno/orgs","repos_url":"https://api.github.com/users/pnaponoceno/repos","events_url":"https://api.github.com/users/pnaponoceno/events{/privacy}","received_events_url":"https://api.github.com/users/pnaponoceno/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pnaponoceno/learning-ruby","description":"Git para estudos de Ruby","fork":false,"url":"https://api.github.com/repos/pnaponoceno/learning-ruby","forks_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/forks","keys_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/teams","hooks_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/hooks","issue_events_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/events","assignees_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/tags","blobs_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/languages","stargazers_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/stargazers","contributors_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/contributors","subscribers_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/subscribers","subscription_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/subscription","commits_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/merges","archive_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/downloads","issues_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/labels{/name}","releases_url":"https://api.github.com/repos/pnaponoceno/learning-ruby/releases{/id}","created_at":"2016-01-01T17:32:46Z","updated_at":"2016-01-11T14:33:34Z","pushed_at":"2016-01-11T18:09:25Z","git_url":"git://github.com/pnaponoceno/learning-ruby.git","ssh_url":"git@github.com:pnaponoceno/learning-ruby.git","clone_url":"https://github.com/pnaponoceno/learning-ruby.git","svn_url":"https://github.com/pnaponoceno/learning-ruby","homepage":null,"size":94,"stargazers_count":29,"watchers_count":29,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":16,"forks":38,"open_issues":16,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50"},"html":{"href":"https://github.com/pnaponoceno/learning-ruby/pull/50"},"issue":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues/50"},"comments":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/pnaponoceno/learning-ruby/statuses/3451e9d6e3c2dd74982d915b3b834d914681eb14"}}}}