{"id":8697,"date":"2019-12-21T15:33:42","date_gmt":"2019-12-21T06:33:42","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=8697"},"modified":"2023-05-27T22:51:25","modified_gmt":"2023-05-27T13:51:25","slug":"%e3%80%90ruby-on-rails%e3%80%91%e3%83%87%e3%83%90%e3%83%83%e3%82%b0%e3%81%ae%e4%bb%95%e6%96%b9%e3%80%8cbyebug%e3%80%8d%e3%82%92%e4%bd%bf%e3%81%86%e5%a0%b4%e5%90%88%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=8697","title":{"rendered":"\u3010Ruby on Rails\u3011\u30c7\u30d0\u30c3\u30b0\u306e\u4ed5\u65b9(Docker\u4e0a\u306e\u30c7\u30d0\u30c3\u30af\u3082\uff09"},"content":{"rendered":"<p>Rails\u3067\u30c7\u30d0\u30c3\u30b0\u3092\u3057\u305f\u3044\u5834\u5408\u306fbyebug\u3068\u3044\u3046\u30c4\u30fc\u30eb\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\uff08Visual Studio Code\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u30b9\u30c6\u30c3\u30d7\u5b9f\u884c\u304c\u3067\u304d\u308b\u306e\u3067\u305d\u3061\u3089\u3092\u4f7f\u3063\u305f\u65b9\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u3002\uff09<\/p>\n<p>Gemfile\u306b\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067<span style=\"color: #ff0000;\"><strong>\u300cbyebug\u300d<\/strong><\/span>\u304c\u958b\u767a\u74b0\u5883\u3060\u3051\u8aad\u307f\u8fbc\u307e\u308c\u308b\u8a2d\u5b9a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">group :development, :test do\r\n  # Call 'byebug' anywhere in the code to stop execution and get a debugger console\r\n  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\r\nend<\/pre>\n<h2>byebug\u306e\u4f7f\u3044\u65b9<\/h2>\n<h3>\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u3092\u8cbc\u308a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6b62\u3081\u3066\u5909\u6570\u306e\u4e2d\u8eab\u3092\u78ba\u8a8d\u3059\u308b\u3002<\/h3>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3084\u30e2\u30c7\u30eb\u3068\u304b\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6b62\u3081\u305f\u3044\u4efb\u610f\u306e\u7b87\u6240\u3067\u4e0b\u8a18\u306e\u8a18\u8ff0\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">byebug<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068byebug\u3092\u8a18\u8ff0\u3057\u305f\u7b87\u6240\u3067\u51e6\u7406\u304c\u6b62\u307e\u308b\u306e\u3067\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u3067\u5909\u6570\u3092\u6253\u3064\u3068\u5909\u6570\u306e\u4e2d\u8eab\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\uff08\u4e0b\u8a18\u4f8b\u3067\u306f\u753b\u9762\u304b\u3089\u9001\u3089\u308c\u3066\u304d\u305fparams\u3068\u3044\u3046\u5909\u6570\u306e\u4e2d\u8eab\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-8700\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2019\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2019-12-21-15.40.32.png\" alt=\"\" width=\"2520\" height=\"434\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2019\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2019-12-21-15.40.32.png 2520w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2019\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2019-12-21-15.40.32-300x52.png 300w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2019\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2019-12-21-15.40.32-768x132.png 768w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2019\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2019-12-21-15.40.32-1024x176.png 1024w\" sizes=\"(max-width: 2520px) 100vw, 2520px\" \/><\/p>\n<h3>byebug\u306e\u30b3\u30de\u30f3\u30c9<\/h3>\n<table>\n<tbody>\n<tr>\n<th>\u30b3\u30de\u30f3\u30c9<\/th>\n<th>\u51e6\u7406\u5185\u5bb9<\/th>\n<\/tr>\n<tr>\n<td>n<\/td>\n<td>\u30b9\u30c6\u30c3\u30d7\u30aa\u30fc\u30d0\u30fc<\/td>\n<\/tr>\n<tr>\n<td>s<\/td>\n<td>\u30b9\u30c6\u30c3\u30d7\u30a4\u30f3<\/td>\n<\/tr>\n<tr>\n<td>c<\/td>\n<td>\u5b9f\u884c\u7d99\u7d9a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>byebug\u3092\u7d42\u4e86\u3059\u308b\u3002<\/h3>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068byebug\u306f\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">quit<\/pre>\n<p>\u305d\u306e\u969b\u306fRails\u30b5\u30fc\u30d0\u3082\u7d42\u4e86\u3059\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h2>Docker\u4e0a\u306eRails\u30c7\u30d0\u30c3\u30af<\/h2>\n<h3>docker-compose.yml<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u300ctty: true\u300d<\/strong><\/span>\u3068<span style=\"color: #ff0000;\"><strong>\u300cstdin_open: true\u300d<\/strong><\/span>\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">services:\r\n  web:\r\n    build: .\r\n    command: bundle exec rails s -p 3000 -b '0.0.0.0'\r\n    volumes:\r\n      - .:\/app\r\n    ports:\r\n      - 3000:3000\r\n    depends_on:\r\n      - db\r\n    tty: true \u2605\r\n    stdin_open: true \u2605<\/pre>\n<p>\u6b21\u306b\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066Web\u30b5\u30fc\u30d0\u30fc\u306e\u30b3\u30f3\u30c6\u30ca\u540d(name)\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">docker ps<\/pre>\n<p>Rails\u306e\u30b3\u30fc\u30c9\u306b\u300cbyebug\u300d\u3092\u57cb\u3081\u8fbc\u3093\u3060\u3089\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">docker attach Web\u30b5\u30fc\u30d0\u30fc\u306e\u30b3\u30f3\u30c6\u30ca\u540d(docker ps\u3067\u53d6\u5f97)<\/pre>\n<p>\u3053\u308c\u3067\u30c7\u30d0\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u306a\u304aattach\u72b6\u614b\u3092\u89e3\u9664\u3057\u305f\u3044\u5834\u5408\u306f\u4e0b\u8a18\u306e\u30ad\u30fc\u3092\u62bc\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">Ctrl\u30ad\u30fc + p + q<\/pre>\n<p>\u3044\u3061\u3044\u3061\u8abf\u3079\u3066attach\u3059\u308b\u306e\u306f\u9762\u5012\u3060\u3068\u601d\u3046\u306e\u3067\u3001\u6bce\u56dedocker ps\u306b\u3066\u30b3\u30f3\u30c6\u30ca\u540d\u3092\u8abf\u3079\u308b\u306e\u306f\u9762\u5012\u3060\u3068\u601d\u3046\u306e\u3067\u3001\u4e0b\u8a18\u306e\u8d77\u52d5\u65b9\u6cd5\u3092\u3059\u308c\u3070\u697d\u306b\u30a2\u30bf\u30c3\u30c1\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\uff08\u5185\u90e8\u7684\u306a\u52d5\u304d\u3068\u3057\u3066\u306f\u3001\u30a2\u30bf\u30c3\u30c1\u3057\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002\uff09<\/p>\n<pre class=\"lang:default decode:true \">.\/bin\/docker-compose-attach web\uff08Web\u30b5\u30fc\u30d0\u30fc\u306e\u30b3\u30f3\u30c6\u30ca\u540d\uff09<\/pre>\n","protected":false},"excerpt":{"rendered":"Rails\u3067\u30c7\u30d0\u30c3\u30b0\u3092\u3057\u305f\u3044\u5834\u5408\u306fbyebug\u3068\u3044\u3046\u30c4\u30fc\u30eb\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\uff08Visual Studio Code\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u30b9\u30c6\u30c3\u30d7\u5b9f\u884c\u304c\u3067\u304d\u308b\u306e\u3067\u305d\u3061\u3089\u3092\u4f7f\u3063\u305f\u65b9\u304c\u826f\u3044\u3067\u3057\u3087\u3046\u3002\uff09 Gemfile\u306b\u306f\u30c7\u30d5\u30a9 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[36],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8697"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8697"}],"version-history":[{"count":7,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8697\/revisions"}],"predecessor-version":[{"id":20520,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8697\/revisions\/20520"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8697"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}