{"published":"2025-07-12 03:45:10","description":"\u4eca\u56de\u306f\u3001Ruby\u3067\u304a\u306a\u3058\u307f\u306eNoMethodError\u306b\u3055\u3088\u3046\u306a\u3089\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\uff01 user.profile.name \u3053\u3046\u3044\u3046\u30b3\u30fc\u30c9\u3001\u66f8\u3044\u305f\u3053\u3068\u3042\u308a\u307e\u305b\u3093\u304b\uff1f \u3067\u3082\u3001user\u3084profile\u304cnil\u3060\u3068\u3001\u300cundefined method `name' for nil:NilClass\u300d \u3063\u3066\u6012\u3089\u308c\u3061\u3083\u3046\u3002 \u3053\u308c\u3001\u3088\u304f\u3042\u308b\u3051\u3069\u5730\u5473\u306b\u30c4\u30e9\u3044\u30a8\u30e9\u30fc\u3067\u3059\u3088\u306d\u3002 \u305d\u3082\u305d\u3082\u4f55\u304c\u554f\u984c\u306a\u306e\uff1f Ruby\u3067\u306f nil \u306b\u5bfe\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3068 NoMethodError \u304c\u8d77\u304d\u307e\u3059\u3002 user = nil puts user.name # => \u30a8\u30e9\u30fc\uff01 \u3053\u308c\u3001if\u6587\u3067\u56de\u907f\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308b\u3051\u3069\u2026\u30cd\u30b9\u30c8\u304c\u2026","height":"190","image_url":"https://cdn-ak.f.st-hatena.com/images/fotolife/k/kurusaki/20250712/20250712122359.jpg","width":"100%","url":"https://codeboost-labo.hateblo.jp/entry/2025/07/12/034510","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fcodeboost-labo.hateblo.jp%2Fentry%2F2025%2F07%2F12%2F034510\" title=\"NoMethodError\u306b\u3055\u3088\u3046\u306a\u3089\uff01Ruby\u306e\u30bb\u30fc\u30d5\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u6f14\u7b97\u5b50\uff08\u307c\u3063\u3061\u6f14\u7b97\u5b50\uff09\u3092\u4f7f\u3044\u3053\u306a\u305d\u3046 - CodeBoost Labo\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","categories":["Ruby\u3092\u6df1\u6398\u308a\uff01\u672c\u8cea\u304b\u3089\u5b66\u3076\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8b1b\u5ea7"],"blog_url":"https://codeboost-labo.hateblo.jp/","author_name":"kurusaki","type":"rich","version":"1.0","provider_url":"https://hatena.blog","title":"NoMethodError\u306b\u3055\u3088\u3046\u306a\u3089\uff01Ruby\u306e\u30bb\u30fc\u30d5\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u6f14\u7b97\u5b50\uff08\u307c\u3063\u3061\u6f14\u7b97\u5b50\uff09\u3092\u4f7f\u3044\u3053\u306a\u305d\u3046","blog_title":"CodeBoost Labo","author_url":"https://blog.hatena.ne.jp/kurusaki/","provider_name":"Hatena Blog"}