{"id":8730,"date":"2019-12-22T15:46:37","date_gmt":"2019-12-22T06:46:37","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=8730"},"modified":"2023-05-27T22:32:21","modified_gmt":"2023-05-27T13:32:21","slug":"%e3%80%90ruby%e3%80%91%e3%80%8cpry%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=8730","title":{"rendered":"\u3010Ruby\u3011REPL(IRB\u3001pry\uff09\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>REPL\u3068\u306f\uff1f<\/h2>\n<p>\u5165\u529b\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3092\u8a55\u4fa1\u3057\u3066\u8868\u793a\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u4e3b\u306bRuby\u3067\u306f\u4e0b\u8a18\u306e\u30c4\u30fc\u30eb\u304c\u6709\u540d\u3067\u3059\u3002<\/p>\n<ul>\n<li>IRB<\/li>\n<li>pry<\/li>\n<\/ul>\n<h2>IRB\u3068\u306f\uff1f<\/h2>\n<p>Ruby\u6a19\u6e96\u306eREPL\u3067\u3059\u3002<\/p>\n<h2>pry\u3068\u306f\uff1f<\/h2>\n<p>IRB\u3068\u540c\u3058\u3088\u3046\u306b\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306bRuby\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u3067\u3059\u304c\u3001\u6a19\u6e96\u3067\u3064\u3044\u3066\u304a\u3089\u305aGem\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002IRB\u306e\u6a5f\u80fd\u306b\u52a0\u3048\u3066\u4e0b\u8a18\u306e\u3088\u3046\u306a\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>\u6a5f\u80fd<\/h3>\n<ul>\n<li>\u30b3\u30fc\u30c9\u306e\u30ab\u30e9\u30fc\u30ea\u30f3\u30b0<\/li>\n<li>\u81ea\u52d5\u30a4\u30f3\u30c7\u30f3\u30c8<\/li>\n<li>\u30b3\u30fc\u30c9\u306e\u4fdd\u7ba1\u6a5f\u80fd\uff08\u30b3\u30fc\u30c9\u3092\u9014\u4e2d\u307e\u3067\u5165\u308c\u3066\u9014\u4e2d\u3067Tab\u5165\u529b\u3068\u304b\u3001Tab2\u56de\u62bc\u3057\u3067\u5019\u88dc\u8868\u793a\u3082\u53ef\u80fd\uff09<\/li>\n<\/ul>\n<h3>pry\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<pre class=\"lang:default decode:true \">gem install pry<\/pre>\n<h2>Rails\u3078\u306e\u5c0e\u5165<\/h2>\n<p>Rails\u3078pry\u3092\u5c0e\u5165\u3059\u308b\u5834\u5408\u306fGemfile\u306edevelopment\u3078\u4e0b\u8a18\u306e\u8a18\u8ff0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">group :development do\r\n  # Access an IRB console on exception pages or by using &lt;%= console %&gt; anywhere in the code.\r\n  gem 'web-console'\r\n  gem 'listen', '~&gt; 3.0.5'\r\n  # Spring speeds up development by keeping your application running in the background. Read more: https:\/\/github.com\/rails\/spring\r\n  gem 'spring'\r\n  gem 'spring-watcher-listen', '~&gt; 2.0.0'\r\n  gem 'pry-byebug'\u3000\u2605\u8ffd\u52a0\r\nend<\/pre>\n<p>Docker\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3042\u308c\u3070\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u3053\u308c\u3067<span style=\"color: #ff0000;\"><strong>\u30a2\u30bf\u30c3\u30c1\u72b6\u614b\uff08pry\u306b\u3088\u308b\u30c7\u30d0\u30c3\u30b0\u304c\u53ef\u80fd\u306a\u72b6\u614b\uff09\u306b\u79fb\u884c<\/strong><\/span>\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">docker attach [Rails\u304c\u8f09\u3063\u3066\u3044\u308b\u30b3\u30f3\u30c6\u30ca\u540d]<\/pre>\n<p>\u6bce\u56dedocker-compose 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<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">binding.pry<\/pre>\n<p>Rails\u3092\u5b9f\u884c\u3057\u305f\u969b\u306b\u4e0a\u8a18\u30b3\u30fc\u30c9\u306b\u5230\u9054\u3057\u305f\u3089\u753b\u9762\u304c\u505c\u6b62\u3057\u30c7\u30d0\u30c3\u30b0\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>pry\u3067\u306e\u30c7\u30d0\u30c3\u30b0\u72b6\u614b\u3092\u7d42\u4e86\u3055\u305b\u308b\u306b\u306f\uff1f<\/h3>\n<p>\u4e0b\u8a18\u306e\u3044\u305a\u308c\u304b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>exit<\/li>\n<li>continue<\/li>\n<\/ul>\n<h3>\u30a2\u30bf\u30c3\u30c1\u72b6\u614b(pry\u306b\u3088\u308b\u30c7\u30d0\u30c3\u30b0\u304c\u53ef\u80fd\u306a\u72b6\u614b)\u3092\u629c\u3051\u308b\u306b\u306f\uff1f<\/h3>\n<p>\u4e0b\u8a18\u306e\u30b7\u30e7\u30fc\u30c8\u30ab\u30c3\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>Ctrl + p + q<\/li>\n<\/ul>\n<h2>pry\u306e\u7a2e\u985e<\/h2>\n<p>Rails\u3067\u4f7f\u3048\u308bpry\u306b\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b3\u7a2e\u985e\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>pry<\/li>\n<li>pry-rails<\/li>\n<li>pry-byebug<\/li>\n<\/ul>\n<h3>pry<\/h3>\n<p>\u901a\u5e38\u306epry\u3067\u3059\u3002binding.pry\u3067\u666e\u901a\u306b\u30c7\u30d0\u30c3\u30af\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>pry-rails<\/h3>\n<p>rails\u30b3\u30f3\u30bd\u30fc\u30eb\u5185\u3067pry\u3092\u4f7f\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002pry\u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b\u306e\u3067\u3001pry-rails\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u5fc5\u305a\u901a\u5e38\u306epry\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002\u306a\u306e\u3067\u3001\u3053\u308c\u3092\u4f7f\u3046\u5834\u5408\u306f\u5197\u9577\u306b\u306a\u308b\u306e\u3067Gemfile\u306bgem 'pry'\u7b49\u3068\u8a18\u8ff0\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>pry-byebug<\/h3>\n<p>\u3053\u308c\u3092\u4f7f\u3048\u3070pry\u3067\u6b62\u3081\u305f\u7b87\u6240\u304b\u3089\u30b9\u30c6\u30c3\u30d7\u5b9f\u884c\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"REPL\u3068\u306f\uff1f \u5165\u529b\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3092\u8a55\u4fa1\u3057\u3066\u8868\u793a\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u4e3b\u306bRuby\u3067\u306f\u4e0b\u8a18\u306e\u30c4\u30fc\u30eb\u304c\u6709\u540d\u3067\u3059\u3002 IRB pry IRB\u3068\u306f\uff1f Ruby\u6a19\u6e96\u306eREPL\u3067\u3059\u3002 pry\u3068\u306f\uff1f IRB\u3068\u540c\u3058\u3088\u3046\u306b\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306bRuby [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[48],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8730"}],"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=8730"}],"version-history":[{"count":11,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8730\/revisions"}],"predecessor-version":[{"id":20471,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/8730\/revisions\/20471"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8730"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}