{"id":1314,"date":"2020-05-10T15:36:57","date_gmt":"2020-05-10T06:36:57","guid":{"rendered":"http:\/\/168.138.214.208\/?p=1314"},"modified":"2020-05-18T09:03:39","modified_gmt":"2020-05-18T00:03:39","slug":"post-1314","status":"publish","type":"post","link":"https:\/\/nobunobu1717.site\/?p=1314","title":{"rendered":"Heroku\u3067Ruby on Rails(postgres)\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u307e\u3067\u306e\u30e1\u30e2"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">1<\/span> \u6982\u8981<\/a><\/li><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_1\">2<\/span> \u74b0\u5883\u53ca\u3073\u524d\u63d0<\/a><\/li><li><a href=\"#i-3\"><span class=\"toc_number toc_depth_1\">3<\/span> \u624b\u9806<\/a><\/li><\/ul><\/div>\n<h2><span id=\"i\">\u6982\u8981<\/span><\/h2>\n<p>rails\u30a2\u30d7\u30ea\u3092heroku\u306b\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u307e\u3067\u306e\u30e1\u30e2\u3002<\/p>\n<p><a href=\"http:\/\/168.138.214.208\/wp-content\/uploads\/2020\/05\/228-heroku-ci-500-281.jpg\"><img src=\"http:\/\/168.138.214.208\/wp-content\/uploads\/2020\/05\/228-heroku-ci-500-281-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" class=\"aligncenter size-medium wp-image-1319\" srcset=\"https:\/\/nobunobu1717.site\/wp-content\/uploads\/2020\/05\/228-heroku-ci-500-281-300x169.jpg 300w, https:\/\/nobunobu1717.site\/wp-content\/uploads\/2020\/05\/228-heroku-ci-500-281.jpg 500w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2><span id=\"i-2\">\u74b0\u5883\u53ca\u3073\u524d\u63d0<\/span><\/h2>\n<p>Mac OS 10.15.4<br \/>\nRuby 2.6.3p62<br \/>\nRails 6.0.2.2<\/p>\n<p>\u4e8b\u524d\u306bheroku\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u6e08<br \/>\ngit\u3068heroku CLI\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08<br \/>\nheroku login\u3067\u30ed\u30b0\u30a4\u30f3\u3092\u884c\u306a\u3063\u3066\u3044\u308b<\/p>\n<h2><span id=\"i-3\">\u624b\u9806<\/span><\/h2>\n<h3>\u30a2\u30d7\u30ea\u306e\u4f5c\u6210<\/h3>\n<pre class=\"lang:default decode:true \" >\r\nheroku create &lt;\u30a2\u30d7\u30ea\u540d&gt;\r\n\r\nCreating \u2b22 &lt;\u30a2\u30d7\u30ea\u540d&gt;... done\r\nhttps:\/\/&lt;\u30a2\u30d7\u30ea\u540d&gt;.herokuapp.com\/ | https:\/\/git.heroku.com\/&lt;\u30a2\u30d7\u30ea\u540d&gt;.git\r\n<\/pre>\n<p>\u3067\u30a2\u30d7\u30ea\u304c\u4f5c\u3089\u308c\u308b\u3002<\/p>\n<p>remote\u30ec\u30dd\u30b8\u30c8\u30ea\u3092\u8ffd\u52a0<br \/>\ngit remote add heroku https:\/\/git.heroku.com\/<\u30a2\u30d7\u30ea\u540d>.git<\/p>\n<p>Heroku\u306e\u30a2\u30c9\u30aa\u30f3\u3092\u8ffd\u52a0<br \/>\nheroku config\u3067DATABASE_URL\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u5834\u5408\u306b\u306f\u30a2\u30c9\u30aa\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<p>heroku addons:create heroku-postgresql:hobby-dev<\/p>\n<h3>\u30a2\u30d7\u30ea\u306e\u8a2d\u5b9a<\/h3>\n<p>database.yml\u306e\u4fee\u6b63<br \/>\n\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3068heroku\u3067\u8a2d\u5b9a\u304c\u7570\u306a\u308b\u306e\u3067\u5206\u96e2\u3002<br \/>\n\u30ed\u30fc\u30ab\u30eb\u306f\u30dd\u30fc\u30c8\u3084\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u6307\u5b9a\u3002<br \/>\nheroku\u306fURL\u3067\u6307\u5b9a\u3059\u308b\u3068\u3001\u305d\u3053\u306b\u30a2\u30ab\u30a6\u30f3\u30c8\u3084DB\u540d\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u306e\u3067\u6307\u5b9a\u304c\u4e0d\u8981\u3002<br \/>\nheroku config\u3067DATABASE_URL\u3067\u8a2d\u5b9a\u3055\u308c\u305fURL\u3092\u8a18\u8f09\u3059\u308b\u3002<br \/>\n\u4eca\u56de\u306f.env\u30d5\u30a1\u30a4\u30eb\u306b\u8a2d\u5b9a\u3092\u8a18\u8f09\u3057\u3066\u5b9f\u65bd\u3057\u3066\u3044\u308b\u3002<br \/>\n\u53c2\u8003:https:\/\/pikawaka.com\/rails\/dotenv-rails<\/p>\n<pre class=\"lang:yaml decode:true \" >default: &amp;default\r\n  adapter: postgresql\r\n  encoding: utf8\r\n  # For details on connection pooling, see Rails configuration guide\r\n  # https:\/\/guides.rubyonrails.org\/configuring.html#database-pooling\r\n  pool: &lt;%= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } %&gt;\r\n\r\n\r\ndevelopment:\r\n  &lt;&lt;: *default\r\n  database: dev_suruga_db\r\n  username: test\r\n  password: password\r\n  host: localhost\r\n  port: 15432\r\n\r\ntest:\r\n  &lt;&lt;: *default\r\n  database: test_suruga_db\r\n  username: test\r\n  password: password\r\n  host: localhost\r\n  port: 15432\r\n\r\nproduction:\r\n  &lt;&lt;: *default\r\n  url: &lt;%= ENV['PROD_DATABASE_URL'] %&gt;\r\n  port: 5432\r\n<\/pre>\n<h3>\u30c7\u30d7\u30ed\u30a4<\/h3>\n<p>git push heroku master<br \/>\n\u3067\u30c7\u30d7\u30ed\u30a4\u3002<\/p>\n<p>rails db:migrate\u3084seed\u3067\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u306e\u30af\u30ea\u30a2<\/h3>\n<p>rails db:reset\u306a\u3069\u3067\u30c7\u30fc\u30bf\u3092\u6d88\u3057\u305f\u3044\u5834\u5408\u306b\u306f<br \/>\nheroku pg:reset -a \u30a2\u30d7\u30ea\u540d<br \/>\n\u3067\u5b9f\u65bd\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3002(\u78ba\u8a8d\u7528\u306e\u30b3\u30de\u30f3\u30c9\u3092\u305d\u306e\u5f8c\u6253\u3061\u8fbc\u3080\uff09<br \/>\n\u305d\u306e\u5f8c\u306b\u3000rails db:migrate\u3092\u5b9f\u65bd\u3002<\/p>\n<p>\u53c2\u8003:https:\/\/qiita.com\/yusuke_s221\/items\/cefb1808fdf481e6e445<\/p>\n<h3>\u74b0\u5883\u5909\u6570\u306e\u9069\u5fdc<\/h3>\n<p>.env\u30d5\u30a1\u30a4\u30eb\u3067\u74b0\u5883\u5909\u6570\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u306b\u306f\u4e0b\u8a18\u3092\u5b9f\u884c\u3057\u3066\u53cd\u6620\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true \" >heroku plugins:install heroku-config\r\nheroku config:push<\/pre>\n<p>Redis\u3092\u4f7f\u3046\u5834\u5408\u306f\u4e0b\u8a18\u6ce8\u610f<\/p>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" title=\"Heroku Redis \u306f\u521d\u671f\u8a2d\u5b9a\u3067\u5229\u7528\u3057\u3066\u306f\u306a\u3089\u306a\u3044 - \u30dc\u30af\u30b3\u30b3\" src=\"https:\/\/hatenablog-parts.com\/embed?url=https%3A%2F%2Fwww.bokukoko.info%2Fentry%2F2015%2F09%2F05%2FHeroku_Redis_%25E3%2581%25AF%25E5%2588%259D%25E6%259C%259F%25E8%25A8%25AD%25E5%25AE%259A%25E3%2581%25A7%25E5%2588%25A9%25E7%2594%25A8%25E3%2581%2597%25E3%2581%25A6%25E3%2581%25AF%25E3%2581%25AA%25E3%2582%2589%25E3%2581%25AA%25E3%2581%2584#?secret=mM85PtluKi\" data-secret=\"mM85PtluKi\" scrolling=\"no\" frameborder=\"0\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 \u6982\u89812 \u74b0\u5883\u53ca\u3073\u524d\u63d03 \u624b\u9806 \u6982\u8981 rails\u30a2\u30d7\u30ea\u3092heroku\u306b\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u307e\u3067\u306e\u30e1\u30e2\u3002 \u74b0\u5883\u53ca\u3073\u524d\u63d0 Mac OS 10.15.4 Ruby 2.6.3p62 Rails 6 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1319,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,32],"tags":[],"_links":{"self":[{"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/posts\/1314"}],"collection":[{"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1314"}],"version-history":[{"count":9,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/posts\/1314\/revisions"}],"predecessor-version":[{"id":1337,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/posts\/1314\/revisions\/1337"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=\/wp\/v2\/media\/1319"}],"wp:attachment":[{"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nobunobu1717.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}