{"id":3114,"date":"2021-12-11T06:35:57","date_gmt":"2021-12-10T21:35:57","guid":{"rendered":"https:\/\/suzutukiblog.com\/?p=3114"},"modified":"2022-01-23T07:54:07","modified_gmt":"2022-01-22T22:54:07","slug":"rails-tutorial14-3","status":"publish","type":"post","link":"https:\/\/suzutukiblog.com\/index.php\/2021\/12\/11\/rails-tutorial14-3\/","title":{"rendered":"Rails-tutorial\u306e\u307e\u3068\u3081(14.3 \u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9)"},"content":{"rendered":"<p><a href=\"https:\/\/suzutukiblog.com\/index.php\/2021\/04\/26\/rails-tutorial14-25\/\">\u305d\u306e14.25\u304b\u3089\u7d9a\u304f<\/a><\/p>\n<h3>14.3 \u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9<\/h3>\n<p>\u6700\u5f8c\u306e\u96e3\u95a2\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u306b\u53d6\u308a\u304b\u304b\u308a\u307e\u3057\u3087\u3046\u3002<br \/>\n\u672c\u66f8\u306e\u4e2d\u3067\u3082\u6700\u3082\u9ad8\u5ea6\u306a\u3082\u306e\u3067\u3059\u3002\u5b8c\u5168\u306a\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306f\u3001<br \/>\n13\u7ae0\u3067\u6271\u3063\u305f\u30d7\u30ed\u30c8\u30d5\u30a3\u30fc\u30c9\u3092\u30d9\u30fc\u30b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u30d5\u30a9\u30ed\u30fc\u3055\u308c\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u306e\u914d\u5217\u3092\u4f5c\u6210\u3057\u3001\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u81ea\u8eab\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u3068\u5408\u308f\u305b\u3066\u8868\u793a\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u901a\u3057\u3066\u3001\u8907\u96d1\u3055\u3092\u5897\u3057\u305f\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u306b\u9032\u3093\u3067\u3044\u304d\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u306f\u3001Rails\u3068Ruby\u306e\u9ad8\u5ea6\u306a\u6a5f\u80fd\u306e\u4ed6\u306b\u3001<br \/>\nSQL\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u6280\u8853\u3082\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h3>14.3.1 \u52d5\u6a5f\u3068\u8a08\u753b<\/h3>\n<p>\u30d5\u30a3\u30fc\u30c9\u306b\u5fc5\u8981\u306a\uff13\u3064\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\u3053\u3068\u3067\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u3001<\/p>\n<h4>1) \u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u304c\u30d5\u30a3\u30fc\u30c9\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u3053\u3068<br \/>\n2) \u81ea\u5206\u81ea\u8eab\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u3082\u30d5\u30a3\u30fc\u30c9\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u3053\u3068\u3002<br \/>\n3) \u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u304c\u30d5\u30a3\u30fc\u30c9\u306b\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u3053\u3068<\/h4>\n<p>\u306e\uff13\u3064\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a\u306fMichael\u304cLana\u3092\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u3066\u3001<br \/>\nArcher\u3092\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u72b6\u6cc1\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u3053\u306e\u72b6\u6cc1\u306eMichael\u306e\u30d5\u30a3\u30fc\u30c9\u3067\u306f\u3001Lana\u3068\u81ea\u5206\u81ea\u8eab\u306e\u6295\u7a3f\u304c\u898b\u3048\u3066\u3044\u3066\u3001Archer\u306e\u6295\u7a3f\u306f\u898b\u3048\u306a\u3044\u3053\u3068\u306b\u306a\u308a\u307e\u3059<\/p>\n<p>\u5148\u307b\u3069\u306e\uff13\u3064\u306e\u6761\u4ef6\u3092\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306b\u5909\u63db\u3057\u3066\u3001<br \/>\nUser\u30e2\u30c7\u30eb\u306bfeed\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u306a\u304c\u3089\u3001<br \/>\n\u66f4\u65b0\u3057\u305fUser\u30e2\u30c7\u30eb\u306b\u5bfe\u3059\u308b\u30c6\u30b9\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u7d50\u679c\u3092\u2193\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306e\u30c6\u30b9\u30c8<br \/>\n<strong>test\/models\/user_test.rb<\/strong><\/p>\n<h3>\u6f14\u7fd2<\/h3>\n<p>\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u306eid\u304c\u6b63\u3057\u304f\u4e26\u3093\u3067\u3044\u308b\u3068\u4eee\u5b9a\u3057\u3066<br \/>\n(\u3059\u306a\u308f\u3061\u82e5\u3044id\u306e\u6295\u7a3f\u307b\u3069\u53e4\u304f\u306a\u308b\u524d\u63d0\u3067)\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067<br \/>\nuser.feed.map(&amp;:id)\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001<br \/>\n\u3069\u306e\u3088\u3046\u306a\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u308b\u3067\u3057\u3087\u3046\u304b? \u8003\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u305fdefault_scope\u3092\u601d\u3044\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>user.feed.map($:id)<\/strong>\r\n<strong>=&gt;[1,2,7,8,10]<\/strong><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u5f15\u6570\u3068\u3057\u3066\u53d7\u3051\u53d6\u3063\u305f\u81ea\u5206\u306eid\u3068\u3001<br \/>\n\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308bid\u304c\u7d44\u307f\u5408\u308f\u3055\u3063\u3066\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<h3>14.3.2 \u30d5\u30a3\u30fc\u30c9\u3092\u521d\u3081\u3066\u5b9f\u88c5\u3059\u308b<\/h3>\n<p>\u65e9\u901f\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u306b\u7740\u624b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u6700\u7d42\u7684\u306a\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u306f\u3084\u3084\u8fbc\u307f\u5165\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u7d30\u304b\u3044\u90e8\u54c1\u30921\u3064\u305a\u3064\u78ba\u304b\u3081\u306a\u304c\u3089\u5c0e\u5165\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d5\u30a3\u30fc\u30c9\u3067\u5fc5\u8981\u306a\u30af\u30a8\u30ea\u306b\u3064\u3044\u3066\u8003\u3048\u307e\u3057\u3087\u3046\u3002<br \/>\n\u3053\u3053\u3067\u5fc5\u8981\u306a\u306e\u306f\u3001microposts\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u3001<br \/>\n\u3042\u308b\u30e6\u30fc\u30b6\u30fc (\u3064\u307e\u308a\u81ea\u5206\u81ea\u8eab) \u304c\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306b\u5bfe\u5fdc\u3059\u308bid\u3092\u6301\u3064\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u3092\u3059\u3079\u3066\u9078\u629e (select) \u3059\u308b\u3053\u3068\u3067\u3059\u3002<br \/>\n\u3053\u306e\u30af\u30a8\u30ea\u3092\u6a21\u5f0f\u7684\u306b\u66f8\u304f\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong><span class=\"k\">SELECT<\/span> <span class=\"o\">*<\/span> <span class=\"k\">FROM<\/span> <span class=\"n\">microposts<\/span>\r\n<span class=\"k\">WHERE<\/span> <span class=\"n\">user_id<\/span> <span class=\"k\">IN<\/span> <span class=\"p\">(<\/span><span class=\"o\">&lt;<\/span><span class=\"n\">list<\/span> <span class=\"k\">of<\/span> <span class=\"n\">ids<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">)<\/span> <span class=\"k\">OR<\/span> <span class=\"n\">user_id<\/span> <span class=\"o\">=<\/span> <span class=\"o\">&lt;<\/span><span class=\"k\">user<\/span> <span class=\"n\">id<\/span><span class=\"o\">&gt;<\/span><\/strong><\/pre>\n<p>SQL\u304cIN\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u306b\u3057\u3066\u3044\u307e\u3059<\/p>\n<p>\u3053\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001<br \/>\nid\u306e\u96c6\u5408\u306e\u5185\u5305 (set inclusion) \u306b\u5bfe\u3057\u3066\u30c6\u30b9\u30c8\u3092\u884c\u3048\u307e\u3059\u3002<\/p>\n<p>Active Record\u306ewhere\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u601d\u3044\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u3068\u304d\u306b\u9078\u629e\u3059\u3079\u304d\u5bfe\u8c61\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3001<br \/>\n\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u30e6\u30fc\u30b6\u30fcid\u3092\u6301\u3064\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u3092\u9078\u629e\u3059\u308c\u3070\u3088\u304b\u3063\u305f\u306e\u3067\u3057\u305f\u3002<\/p>\n<pre><strong>Micropost.where(\"user_id = ?\", id)<\/strong><\/pre>\n<p>\u4eca\u56de\u5fc5\u8981\u306b\u306a\u308b\u9078\u629e\u306f\u3001\u4e0a\u3088\u308a\u3082\u5c11\u3057\u8907\u96d1\u3067\u3001\u4f8b\u3048\u3070\u6b21\u306e\u3088\u3046\u306a\u5f62\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>Micropost.where(\"user_id IN (?) OR user_id = ?\", following_ids, id)<\/strong><\/pre>\n<p>\u30d5\u30a9\u30ed\u30fc\u3055\u308c\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306b\u5bfe\u5fdc\u3059\u308bid\u306e\u914d\u5217\u304c\u5fc5\u8981\u3067\u3042\u308b\u3053\u3068\u304c<br \/>\n\u308f\u304b\u3063\u3066\u304d\u307e\u3057\u305f\u3002\u3053\u308c\u3092\u884c\u3046\u65b9\u6cd5\u306e1\u3064\u306f\u3001Ruby\u306emap\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\n\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3059\u3079\u3066\u306e\u300c\u5217\u6319\u53ef\u80fd (enumerable)\u300d\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<br \/>\n(\u914d\u5217\u3084\u30cf\u30c3\u30b7\u30e5\u306a\u3069\u3001\u8981\u7d20\u306e\u96c6\u5408\u3067\u69cb\u6210\u3055\u308c\u308b\u3042\u3089\u3086\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8)\u3067\u4f7f\u3048\u307e\u3059\u3002\u306a\u304a\u3001\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u524d\u306b\u3082\u3082\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\nmap\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u914d\u5217\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>rails console<\/strong>\r\n<strong>&gt;&gt; [1, 2, 3, 4].map { |i| i.to_s }<\/strong>\r\n<strong>=&gt; [\"1\", \"2\", \"3\", \"4\"]<\/strong><\/pre>\n<p>&amp; \u3068\u3001\u30e1\u30bd\u30c3\u30c9\u306b\u5bfe\u5fdc\u3059\u308b\u30b7\u30f3\u30dc\u30eb\u3092\u4f7f\u3063\u305f\u77ed\u7e2e\u8868\u8a18\u304c\u4f7f\u3048\u307e\u3059\u3002<br \/>\n\u3053\u306e\u77ed\u7e2e\u8868\u8a18\u3067\u3042\u308c\u3070\u3001\u5909\u6570i\u3092\u4f7f\u308f\u305a\u306b\u6e08\u307f\u307e\u3059\u3002<\/p>\n<pre><strong>&gt;&gt; [1, 2, 3, 4].map(&amp;:to_s)<\/strong>\r\n<strong>=&gt; [\"1\", \"2\", \"3\", \"4\"]<\/strong>\r\n\r\n<strong>&gt;&gt; [1, 2, 3, 4].map(&amp;:to_s).join(', ')<\/strong>\r\n<strong>=&gt; \"1, 2, 3, 4\"<\/strong><\/pre>\n<p>\u4e0a\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u3048\u3070\u3001user.following\u306b\u3042\u308b\u5404\u8981\u7d20\u306eid\u3092\u547c\u3073\u51fa\u3057\u3001<br \/>\n\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306eid\u3092\u914d\u5217\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>&gt;&gt; User.first.following.map(&amp;:id)<\/strong>\r\n<strong>=&gt; [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,<\/strong>\r\n<strong>19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,<\/strong>\r\n<strong>34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]<\/strong><\/pre>\n<p>\u5b9f\u969b\u3001\u3053\u306e\u624b\u6cd5\u306f\u5b9f\u306b\u4fbf\u5229\u306a\u306e\u3067\u3001Active Record\u3067\u306f\u6b21\u306e\u3088\u3046\u306a\u30e1\u30bd\u30c3\u30c9\u3082\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><strong>&gt;&gt; User.first.following_ids<\/strong>\r\n<strong>=&gt; [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,<\/strong>\r\n<strong>19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,<\/strong>\r\n<strong>34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,<\/strong>\r\n<strong>49, 50, 51]<\/strong><\/pre>\n<p>following_ids\u30e1\u30bd\u30c3\u30c9\u306f\u3001has_many :following\u306e\u95a2\u9023\u4ed8\u3051\u3092\u3057\u305f\u3068\u304d\u306bActive Record\u304c\u81ea\u52d5\u751f\u6210\u3057\u305f\u3082\u306e\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306b\u3088\u308a\u3001user.following\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u5bfe\u5fdc\u3059\u308bid\u3092\u5f97\u308b\u305f\u3081\u306b\u306f\u3001\u95a2\u9023\u4ed8\u3051\u306e\u540d\u524d\u306e\u672b\u5c3e\u306b_ids\u3092\u4ed8\u3051\u8db3\u3059\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002<br \/>\n\u7d50\u679c\u3068\u3057\u3066\u3001\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fcid\u306e\u6587\u5b57\u5217\u306f\u3001<br \/>\n\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>&gt;&gt; User.first.following_ids.join(', ')<\/strong>\r\n<strong>=&gt; \"3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,<\/strong>\r\n<strong>19, 20, 21, 22,\u300023, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,<\/strong>\r\n<strong>34, 35, 36, 37, 38, 39, 40, 41,\u300042, 43, 44, 45, 46, 47, 48,<\/strong>\r\n<strong>49, 50, 51\"<\/strong><\/pre>\n<p>\u5b9f\u969b\u306bSQL\u6587\u5b57\u5217\u306b\u633f\u5165\u3059\u308b\u3068\u304d\u306f\u3001\u3053\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u5b9f\u306f\u3001?\u3092\u5185\u633f\u3059\u308b\u3068\u81ea\u52d5\u7684\u306b\u3053\u306e\u8fba\u308a\u306e\u9762\u5012\u3092\u898b\u3066\u304f\u308c\u307e\u3059\u3002<br \/>\n\u3055\u3089\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4f9d\u5b58\u3059\u308b\u4e00\u90e8\u306e\u975e\u4e92\u63db\u6027\u307e\u3067\u89e3\u6d88\u3057\u3066\u304f\u308c\u307e\u3059\u3002<br \/>\n\u3064\u307e\u308a\u3001\u3053\u3053\u3067\u306ffollowing_ids\u30e1\u30bd\u30c3\u30c9\u3092\u305d\u306e\u307e\u307e\u4f7f\u3048\u3070\u3088\u3044\u3060\u3051\u306a\u306e\u3067\u3059\u3002\u7d50\u679c\u3001\u6700\u521d\u306b\u60f3\u50cf\u3057\u3066\u3044\u305f\u3068\u304a\u308a\u3001<\/p>\n<pre><strong>Micropost.where(\"user_id IN (?) OR user_id = ?\", <\/strong><strong>following_ids, id)<\/strong><\/pre>\n<div class=\"heading\"><span class=\"description\">\u3068\u308a\u3042\u3048\u305a\u52d5\u304f\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u00a0<span class=\"smallcaps\"><strong>green<\/strong><\/span><\/span><\/div>\n<div class=\"heading\"><strong><span class=\"description\"><code class=\"filepath\">app\/models\/user.rb<\/code><\/span><\/strong><\/div>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre><strong><span class=\"k\">class<\/span> <span class=\"nc\">User<\/span> <span class=\"o\">&lt;<\/span> <span class=\"no\">ApplicationRecord<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"c1\"># \u30d1\u30b9\u30ef\u30fc\u30c9\u518d\u8a2d\u5b9a\u306e\u671f\u9650\u304c\u5207\u308c\u3066\u3044\u308b\u5834\u5408\u306ftrue\u3092\u8fd4\u3059<\/span>\r\n  <span class=\"k\">def<\/span> <span class=\"nf\">password_reset_expired?<\/span>\r\n    <span class=\"n\">reset_sent_at<\/span> <span class=\"o\">&lt;<\/span> <span class=\"mi\">2<\/span><span class=\"o\">.<\/span><span class=\"n\">hours<\/span><span class=\"o\">.<\/span><span class=\"n\">ago<\/span>\r\n  <span class=\"k\">end<\/span>\r\n\r\n  <span class=\"c1\"># \u30e6\u30fc\u30b6\u30fc\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u3092\u8fd4\u3059<\/span>\r\n  <span class=\"k\">def<\/span> <span class=\"nf\">feed<\/span>\r\n<span class=\"hll\">    <span class=\"no\">Micropost<\/span><span class=\"o\">.<\/span><span class=\"n\">where<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"user_id IN (?) OR user_id = ?\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">following_ids<\/span><span class=\"p\">,<\/span> <span class=\"nb\">id<\/span><span class=\"p\">)<\/span>\r\n<\/span>  <span class=\"k\">end<\/span>\r\n\r\n  <span class=\"c1\"># \u30e6\u30fc\u30b6\u30fc\u3092\u30d5\u30a9\u30ed\u30fc\u3059\u308b<\/span>\r\n  <span class=\"k\">def<\/span> <span class=\"nf\">follow<\/span><span class=\"p\">(<\/span><span class=\"n\">other_user<\/span><span class=\"p\">)<\/span>\r\n    <span class=\"n\">following<\/span> <span class=\"o\">&lt;&lt;<\/span> <span class=\"n\">other_user<\/span>\r\n  <span class=\"k\">end<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n<span class=\"k\">end<\/span><\/strong><\/pre>\n<\/div>\n<\/div>\n<div class=\"heading\">\u00a0<span class=\"description\"><span class=\"smallcaps\"><strong>green<\/strong><\/span><\/span><\/div>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre><strong>rails test<\/strong><\/pre>\n<\/div>\n<\/div>\n<p>\u3044\u304f\u3064\u304b\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u304a\u3044\u3066\u306f\u3001\u3053\u306e\u521d\u671f\u5b9f\u88c5\u3060\u3051\u3067\u76ee\u7684\u304c\u9054\u6210\u3055\u308c\u3001\u5341\u5206\u306b\u601d\u3048\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3057\u304b\u3057\u306b\u306f\u307e\u3060\u8db3\u308a\u306a\u3044\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u305d\u308c\u304c\u4f55\u306a\u306e\u304b\u3001\u6b21\u306b\u9032\u3080\u524d\u306b\u8003\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n(\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u304c5,000\u4eba\u3082\u3044\u305f\u3089\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b?)\u3002<\/p>\n<h2>\u6f14\u7fd2<\/h2>\n<h3>1:\u73fe\u5728\u306e\u30e6\u30fc\u30b6\u30fc\u81ea\u8eab\u306e\u6295\u7a3f\u3092\u542b\u3081\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u304b? \u307e\u305f\u3001\u305d\u306e\u3088\u3046\u306a\u5909\u66f4\u3092\u52a0\u3048\u308b\u3068\u3001\u3069\u306e\u30c6\u30b9\u30c8\u304c\u5931\u6557\u3059\u308b\u3067\u3057\u3087\u3046\u304b?<\/h3>\n<pre>OR user_id = 1\u3067\u3001\u81ea\u5206\u81ea\u8eab\u306e\u30e6\u30fc\u30b6\u30fcid\u3092\u6e21\u3057\u3066\u3044\u308b\u70b9\u306b\u6ce8\u76ee\u3002\r\n<strong>(user_id IN (3,..,51) OR user_id = 1)<\/strong><\/pre>\n<h3>2:\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u6295\u7a3f\u3092\u542b\u3081\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u304b? \u307e\u305f\u3001\u305d\u306e\u3088\u3046\u306a\u5909\u66f4\u3092\u52a0\u3048\u308b\u3068\u3001\u3069\u306e\u30c6\u30b9\u30c8\u304c\u5931\u6557\u3059\u308b\u3067\u3057\u3087\u3046\u304b?<\/h3>\n<pre><strong>def feed<\/strong>\r\n<strong>  Micropost.where(\"user_id = ?\", following_ids, id)<\/strong>\r\n<strong>end\r\nActiveRecord::PreparedStatementInvalid: wrong number of bind variables (2 for 1) in: user_id = ?<\/strong>\r\n<strong>test\/models\/user_test.rb:15:in `block (2 levels) in &lt;class:UserTest&gt;'<\/strong>\r\n<strong>test\/models\/user_test.rb:14:in `block in &lt;class:UserTest&gt;'<\/strong><\/pre>\n<h3>3:\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u306e\u6295\u7a3f\u3092\u542b\u3081\u308b\u305f\u3081\u306b\u306f<br \/>\n\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u304b?<br \/>\n\u307e\u305f\u3001\u305d\u306e\u3088\u3046\u306a\u5909\u66f4\u3092\u52a0\u3048\u308b\u3068\u3001\u3069\u306e\u30c6\u30b9\u30c8\u304c\u5931\u6557\u3059\u308b\u3067\u3057\u3087\u3046\u304b?<br \/>\n\u81ea\u5206\u81ea\u8eab\u3068\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u3001\u305d\u3057\u3066\u305d\u308c\u4ee5\u5916\u3068\u3044\u3046\u96c6\u5408\u306f\u3001<br \/>\n\u3044\u3063\u305f\u3044\u3069\u3046\u3044\u3063\u305f\u96c6\u5408\u3092\u8868\u3059\u306e\u304b\u8003\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/h3>\n<pre><strong># \u30e6\u30fc\u30b6\u30fc\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u3092\u8fd4\u3059<\/strong>\r\n<strong>def feed<\/strong>\r\n<strong>  Micropost.all<\/strong>\r\n<strong>end<\/strong>\r\n\r\n<strong>Expected true to be nil or false<\/strong>\r\n<strong>test\/models\/user_test.rb:23:in `block (2 levels) in &lt;class:UserTest&gt;'<\/strong>\r\n<strong>test\/models\/user_test.rb:22:in `block in &lt;class:UserTest&gt;'<\/strong>\r\n<strong># \u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u306e\u6295\u7a3f\u3092\u78ba\u8a8d<\/strong>\r\n<strong>archer.microposts.each do |post_unfollowed|<\/strong>\r\n<strong>  assert_not michael.feed.include?(post_unfollowed)<\/strong>\r\n<strong>end<\/strong><\/pre>\n<p>\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u306a\u3044\u3082\u306e\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u306e\u306f\u30c0\u30e1\u3067\u3059<\/p>\n<h3>14.3.3 \u30b5\u30d6\u30bb\u30ec\u30af\u30c8<\/h3>\n<p>\u3064\u307e\u308a\u3001\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u304c5,000\u4eba\u7a0b\u5ea6\u306b\u306a\u308b\u3068Web\u30b5\u30fc\u30d3\u30b9\u5168\u4f53\u304c\u9045\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u3092\u6539\u5584\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>following_ids\u3067\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u3059\u3079\u3066\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b<br \/>\n\u554f\u3044\u5408\u308f\u305b\u3057\u3001\u3055\u3089\u306b\u3001\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u5b8c\u5168\u306a\u914d\u5217\u3092\u4f5c\u308b\u305f\u3081\u306b\u518d\u5ea6\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u554f\u3044\u5408\u308f\u305b\u3057\u3066\u3044\u308b\u70b9\u3067\u3059\u3002<br \/>\nSQL\u306e\u30b5\u30d6\u30bb\u30ec\u30af\u30c8 (subselect) \u3092\u4f7f\u3046\u3068\u89e3\u6c7a\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a3\u30fc\u30c9\u3092\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u304b\u3089\u59cb\u3081\u307e\u3057\u3087\u3046\u3002<br \/>\nwhere\u30e1\u30bd\u30c3\u30c9\u5185\u306e\u5909\u6570\u306b\u3001\u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\u3092\u4f7f\u3046 green<br \/>\n<strong>app\/models\/user.rb<\/strong><\/p>\n<pre><strong><span class=\"k\">class<\/span> <span class=\"nc\">User<\/span> <span class=\"o\">&lt;<\/span> <span class=\"no\">ApplicationRecord<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"c1\"># \u30e6\u30fc\u30b6\u30fc\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u3092\u8fd4\u3059<\/span>\r\n  <span class=\"k\">def<\/span> <span class=\"nf\">feed<\/span>\r\n<span class=\"hll\">    <span class=\"no\">Micropost<\/span><span class=\"o\">.<\/span><span class=\"n\">where<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"user_id IN (:following_ids) OR user_id = :user_id\"<\/span><span class=\"p\">,<\/span>\r\n<\/span><span class=\"hll\">     <span class=\"ss\">following_ids<\/span><span class=\"p\">:<\/span> <span class=\"n\">following_ids<\/span><span class=\"p\">,<\/span> <span class=\"ss\">user_id<\/span><span class=\"p\">:<\/span> <span class=\"nb\">id<\/span><span class=\"p\">)<\/span>\r\n<\/span>  <span class=\"k\">end<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n<span class=\"k\">end<\/span><\/strong><\/pre>\n<p class=\"noindent\">\u3053\u308c\u307e\u3067\u306e\u30b3\u30fc\u30c9<\/p>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre><strong><span class=\"no\">Micropost<\/span><span class=\"o\">.<\/span><span class=\"n\">where<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"user_id IN (?) OR user_id = ?\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">following_ids<\/span><span class=\"p\">,<\/span> <span class=\"nb\">id<\/span><span class=\"p\">)<\/span>\r\n<\/strong><\/pre>\n<\/div>\n<\/div>\n<p class=\"noindent\">\u3092\u6b21\u306e\u3088\u3046\u306b\u7f6e\u304d\u63db\u3048\u307e\u3057\u305f\u3002<\/p>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre><strong><span class=\"no\">Micropost<\/span><span class=\"o\">.<\/span><span class=\"n\">where<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"user_id IN (:following_ids) OR user_id = :user_id\"<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"ss\">following_ids<\/span><span class=\"p\">:<\/span> <span class=\"n\">following_ids<\/span><span class=\"p\">,<\/span> <span class=\"ss\">user_id<\/span><span class=\"p\">:<\/span> <span class=\"nb\">id<\/span><span class=\"p\">)<\/span><\/strong><\/pre>\n<\/div>\n<\/div>\n<p>\u524d\u8005\u306e\u7591\u554f\u7b26\u3092\u4f7f\u3063\u305f\u6587\u6cd5\u3082\u4fbf\u5229\u3067\u3059\u304c\u3001\u540c\u3058\u5909\u6570\u3092\u8907\u6570\u306e\u5834\u6240\u306b\u633f\u5165\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u5f8c\u8005\u306e\u7f6e\u304d\u63db\u3048\u5f8c\u306e\u6587\u6cd5\u3092\u4f7f\u3046\u65b9\u304c\u3088\u308a\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u304b\u3089SQL\u30af\u30a8\u30ea\u306b\u3082\u30461\u3064\u306euser_id\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u7279\u306b\u3001\u6b21\u306eRuby\u30b3\u30fc\u30c9\u306f\u3001<\/p>\n<pre><strong>following_ids<\/strong><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306aSQL\u306b\u7f6e\u304d\u63db\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>following_ids = \"SELECT followed_id FROM relationships<\/strong>\r\n<strong>WHERE follower_id = :user_id\"<\/strong><\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092SQL\u306e\u30b5\u30d6\u30bb\u30ec\u30af\u30c8\u3068\u3057\u3066\u4f7f\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u300c\u30e6\u30fc\u30b6\u30fc1\u304c\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u3059\u3079\u3066\u3092\u9078\u629e\u3059\u308b\u300d\u3068\u3044\u3046SQL\u3092\u65e2\u5b58\u306eSQL\u306b\u5185\u5305\u3055\u305b\u308b\u5f62\u306b\u306a\u308a\u3001\u7d50\u679c\u3068\u3057\u3066SQL\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>SELECT * FROM microposts<\/strong>\r\n<strong>WHERE user_id IN (SELECT followed_id FROM relationships<\/strong>\r\n<strong>                  WHERE follower_id = 1)<\/strong>\r\n<strong>OR user_id = 1<\/strong><\/pre>\n<p>\u96c6\u5408\u306e\u30ed\u30b8\u30c3\u30af\u3092 (Rails\u3067\u306f\u306a\u304f) \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u306b\u4fdd\u5b58\u3059\u308b\u306e\u3067\u3001<br \/>\n\u3088\u308a\u52b9\u7387\u7684\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3082\u3063\u3068\u52b9\u7387\u7684\u306a\u30d5\u30a3\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n(\u3053\u3053\u306b\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u306f\u751f\u306eSQL\u3092\u8868\u3059\u6587\u5b57\u5217\u3067\u3042\u308a\u3001<br \/>\nfollowing_ids\u3068\u3044\u3046\u6587\u5b57\u5217\u306f\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u304f\u3001<br \/>\n\u898b\u3084\u3059\u3055\u306e\u305f\u3081\u306b\u5f0f\u5c55\u958b\u3057\u3066\u3044\u308b\u3060\u3051\u3060\u3068\u3044\u3046\u70b9\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002)<\/p>\n<div class=\"heading\"><span class=\"description\">\u30d5\u30a3\u30fc\u30c9\u306e\u6700\u7d42\u7684\u306a\u5b9f\u88c5\u00a0<span class=\"smallcaps\"><strong>green<\/strong><\/span><\/span><\/div>\n<div class=\"heading\"><strong><span class=\"description\"><code class=\"filepath\">app\/models\/user.rb<\/code><\/span><\/strong><\/div>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre><strong><span class=\"k\">class<\/span> <span class=\"nc\">User<\/span> <span class=\"o\">&lt;<\/span> <span class=\"no\">ApplicationRecord<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"c1\"># \u30e6\u30fc\u30b6\u30fc\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u3092\u8fd4\u3059<\/span>\r\n  <span class=\"k\">def<\/span> <span class=\"nf\">feed<\/span>\r\n    <span class=\"n\">following_ids<\/span> <span class=\"o\">=<\/span> <span class=\"s2\">\"SELECT followed_id FROM relationships<\/span>\r\n<span class=\"s2\">                     WHERE follower_id = :user_id\"<\/span>\r\n    <span class=\"no\">Micropost<\/span><span class=\"o\">.<\/span><span class=\"n\">where<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"user_id IN (<\/span><span class=\"si\">#{<\/span><span class=\"n\">following_ids<\/span><span class=\"si\">}<\/span><span class=\"s2\">)<\/span>\r\n<span class=\"s2\">                     OR user_id = :user_id\"<\/span><span class=\"p\">,<\/span> <span class=\"ss\">user_id<\/span><span class=\"p\">:<\/span> <span class=\"nb\">id<\/span><span class=\"p\">)<\/span>\r\n  <span class=\"k\">end<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n  <span class=\"o\">.<\/span>\r\n<span class=\"k\">end<\/span><\/strong><\/pre>\n<\/div>\n<\/div>\n<p>Rails\u3068Ruby\u3068SQL\u306e\u30b3\u30fc\u30c9\u304c\u8907\u96d1\u306b\u7d61\u307f\u5408\u3063\u3066\u3044\u3066\u5384\u4ecb\u3067\u3059\u304c\u3001<br \/>\n\u3061\u3083\u3093\u3068\u52d5\u4f5c\u3057\u307e\u3059\u3002<\/p>\n<div class=\"heading\"><span class=\"description\"><span class=\"smallcaps\"><strong>green<\/strong><\/span><\/span><\/div>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre><strong>rails test<\/strong><\/pre>\n<\/div>\n<\/div>\n<p>\u5927\u898f\u6a21\u306aWeb\u30b5\u30fc\u30d3\u30b9\u3067\u306f\u3001\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u51e6\u7406\u3092\u4f7f\u3063\u3066\u30d5\u30a3\u30fc\u30c9\u3092\u975e\u540c\u671f\u3067\u751f\u6210\u3059\u308b\u306a\u3069\u306e\u3055\u3089\u306a\u308b\u6539\u5584\u304c\u5fc5\u8981\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre>rails test\r\ngit add -A\r\ngit commit -m \"Add user following\"\r\ngit checkout master\r\ngit merge following-users\r\n<\/pre>\n<\/div>\n<\/div>\n<p class=\"noindent\">\u30b3\u30fc\u30c9\u3092\u30ea\u30dd\u30b8\u30c8\u30ea\u306bpush\u3057\u3066\u3001\u672c\u756a\u74b0\u5883\u306b\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<div class=\"code\">\n<div class=\"highlight\">\n<pre>git push\r\ngit push heroku\r\nheroku pg:reset DATABASE\r\nheroku run rails db:migrate\r\nheroku run rails db:seed<\/pre>\n<\/div>\n<\/div>\n<h3>\u6f14\u7fd2<\/h3>\n<p>1:Home\u30da\u30fc\u30b8\u3067\u8868\u793a\u3055\u308c\u308b1\u30da\u30fc\u30b8\u76ee\u306e\u30d5\u30a3\u30fc\u30c9\u306b\u5bfe\u3057\u3066\u3001<br \/>\n\u7d71\u5408\u30c6\u30b9\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong> test \"feed on Home page\" do\r\n   get root_path\r\n   @user.feed.paginate(page: 1).each do |micropost|\r\n    assert_match CGI.escapeHTML(micropost.content), response.body\r\n  end \r\n end<\/strong><\/pre>\n<p>2:\u671f\u5f85\u3055\u308c\u308bHTML\u3092CGI.escapeHTML\u30e1\u30bd\u30c3\u30c9\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u3066\u3044\u307e\u3059(\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306fCGI.escape\u3068\u540c\u3058\u7528\u9014\u3067\u3059)\u3002<br \/>\n\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u306a\u305cHTML\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3057\u3087\u3046\u304b?\u8003\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u30d2\u30f3\u30c8: \u8a66\u3057\u306b\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3092\u5916\u3057\u3066\u3001<br \/>\n\u5f97\u3089\u308c\u308bHTML\u306e\u5185\u5bb9\u3092\u6ce8\u610f\u6df1\u304f\u8abf\u3079\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u306e\u5185\u5bb9\u304c\u4f55\u304b\u304a\u304b\u3057\u3044\u306f\u305a\u3067\u3059\u3002\u307e\u305f\u3001<br \/>\n\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u691c\u7d22\u6a5f\u80fd (Cmd-F\u3082\u3057\u304f\u306fCtrl-F) \u3092\u4f7f\u3063\u3066<br \/>\n\u300csorry\u300d\u3092\u63a2\u3059\u3068\u539f\u56e0\u306e\u7a76\u660e\u306b\u5f79\u7acb\u3064\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>content\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u3066\u3044\u308b\u70ba\u3001CGI.esapeHTML\u3092\u52a0\u3048\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p>\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u304c\u8ffd\u52a0\u3055\u308c\u3001Ruby on Rails\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e<br \/>\n\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u3068\u3046\u3068\u3046\u5b8c\u6210\u3057\u307e\u3057\u305f\u3002<br \/>\n\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u306f\u3001<br \/>\nRails\u306e\u4e3b\u8981\u306a\u6a5f\u80fd (\u30e2\u30c7\u30eb\u3001\u30d3\u30e5\u30fc\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3001\u30d1\u30fc\u30b7\u30e3\u30eb\u3001before\u30d5\u30a3\u30eb\u30bf\u30fc\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3001\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3001has_many\/belongs_to\/has_many through\u95a2\u9023\u4ed8\u3051\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3001\u30c6\u30b9\u30c6\u30a3\u30f3\u30b0\u3001\u30c7\u30d7\u30ed\u30a4)\u304c\u591a\u6570\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>14.4.1 \u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u6a5f\u80fd\u3092\u62e1\u5f35\u3059\u308b<\/h3>\n<p>Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u4f55\u3089\u304b\u306e\u6a5f\u80fd\u3092\u5b9f\u88c5\u3057\u3066\u3044\u3066\u56f0\u3063\u305f\u3068\u304d\u306f\u3001Rails\u30ac\u30a4\u30c9\u3084Rails API\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u3044\u305a\u308c\u30821,000\u30da\u30fc\u30b8\u3092\u8d85\u3048\u308b\u5927\u578b\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306a\u306e\u3067\u3001<br \/>\n\u4eca\u81ea\u5206\u304c\u3084\u308d\u3046\u3068\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u95a2\u9023\u3059\u308b\u30c8\u30d4\u30c3\u30af\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u3067\u304d\u308b\u3060\u3051\u5ff5\u5165\u308a\u306bGoogle\u3067\u691c\u7d22\u3057\u3001\u81ea\u5206\u304c\u8abf\u3079\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u30c8\u30d4\u30c3\u30af\u306b\u8a00\u53ca\u3057\u3066\u3044\u308b\u30d6\u30ed\u30b0\u3084\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u304c\u306a\u3044\u304b\u3069\u3046\u304b\u3001\u3088\u304f\u63a2\u3059\u3053\u3068\u3067\u3059\u3002<br \/>\nWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u306b\u306f\u5e38\u306b\u56f0\u96e3\u304c\u3064\u304d\u307e\u3068\u3044\u307e\u3059\u3002<br \/>\n\u4ed6\u4eba\u306e\u7d4c\u9a13\u3068\u5931\u6557\u304b\u3089\u5b66\u3076\u3053\u3068\u3082\u91cd\u8981\u3067\u3059\u3002<\/p>\n<h3>14.4.1\u00a0\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u6a5f\u80fd\u3092\u62e1\u5f35\u3059\u308b<\/h3>\n<p>Twitter\u306b\u306f\u3001\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u5165\u529b\u4e2d\u306b@\u8a18\u53f7\u306b\u7d9a\u3051\u3066\u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30b0\u30a4\u30f3\u540d\u3092\u5165\u529b\u3059\u308b\u3068\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u8fd4\u4fe1\u3067\u304d\u308b\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30dd\u30b9\u30c8\u306f\u3001\u5b9b\u5148\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u30d5\u30a3\u30fc\u30c9\u3068\u3001<br \/>\n\u81ea\u5206\u3092\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306b\u306e\u307f\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br \/>\n\u3053\u306e\u8fd4\u4fe1\u6a5f\u80fd\u306e\u7c21\u5358\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u5177\u4f53\u7684\u306b\u306f\u3001@reply\u306f\u53d7\u4fe1\u8005\u306e\u30d5\u30a3\u30fc\u30c9\u3068\u9001\u4fe1\u8005\u306e\u30d5\u30a3\u30fc\u30c9\u306b\u306e\u307f\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u5b9f\u88c5\u3059\u308b\u306b\u306f\u3001microposts\u30c6\u30fc\u30d6\u30eb\u306ein_reply_to\u30ab\u30e9\u30e0\u3068\u3001<br \/>\n\u8ffd\u52a0\u306eincluding_replies\u30b9\u30b3\u30fc\u30d7\u3092Micropost\u30e2\u30c7\u30eb\u306b\u8ffd\u52a0\u3059\u308b<br \/>\n\u5fc5\u8981\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u30b9\u30b3\u30fc\u30d7\u306e\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001<br \/>\nRails\u30ac\u30a4\u30c9\u306eActive Record \u30af\u30a8\u30ea\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u91cd\u306a\u308a\u5f97\u308b\u306e\u3067\u3001<br \/>\n\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u4e00\u610f\u306b\u8868\u3059\u65b9\u6cd5\u3082\u8003\u3048\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3067\u3057\u3087\u3046\u3002<br \/>\n1\u3064\u306e\u65b9\u6cd5\u306f\u3001id\u3068\u540d\u524d\u3092\u7d44\u307f\u5408\u308f\u305b\u3066@1-michael-hartl\u306e\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u3059<\/p>\n<p>\u3082\u30461\u3064\u306e\u65b9\u6cd5\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u306e\u9805\u76ee\u306b\u4e00\u610f\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u8ffd\u52a0\u3057\u3001@reply\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<h3>\u30e1\u30c3\u30bb\u30fc\u30b8\u6a5f\u80fd<\/h3>\n<p>Twitter\u3067\u306f\u3001\u30c0\u30a4\u30ec\u30af\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u884c\u3048\u308b\u6a5f\u80fd\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u6a5f\u80fd\u3092\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046<br \/>\n(\u30d2\u30f3\u30c8: Message\u30e2\u30c7\u30eb\u3068\u3001\u65b0\u898f\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u306b\u30de\u30c3\u30c1\u3059\u308b\u6b63\u898f\u8868\u73fe\u304c\u5fc5\u8981\u306b\u306a\u308b\u3067\u3057\u3087\u3046)\u3002<\/p>\n<h3>\u30d5\u30a9\u30ed\u30ef\u30fc\u306e\u901a\u77e5<\/h3>\n<p>\u30e6\u30fc\u30b6\u30fc\u306b\u65b0\u3057\u304f\u30d5\u30a9\u30ed\u30ef\u30fc\u304c\u5897\u3048\u305f\u3068\u304d\u306b\u30e1\u30fc\u30eb\u3067\u901a\u77e5\u3059\u308b\u6a5f\u80fd\u3092<br \/>\n\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u7d9a\u3044\u3066\u3001\u30e1\u30fc\u30eb\u3067\u306e\u901a\u77e5\u6a5f\u80fd\u3092\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066\u9078\u629e\u53ef\u80fd\u306b\u3057\u3001\u4e0d\u8981\u306a\u5834\u5408\u306f\u901a\u77e5\u3092\u30aa\u30d5\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u30e1\u30fc\u30eb\u5468\u308a\u3067\u5206\u304b\u3089\u306a\u3044\u3053\u3068\u304c\u3042\u3063\u305f\u3089\u3001<br \/>\nRails\u30ac\u30a4\u30c9\u306eAction Mailer\u306e\u57fa\u790e\u306b\u30d2\u30f3\u30c8\u304c\u306a\u3044\u304b\u8abf\u3079\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>RSS\u30d5\u30a3\u30fc\u30c9<\/h3>\n<p>\u30e6\u30fc\u30b6\u30fc\u3054\u3068\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u3092RSS\u30d5\u30a3\u30fc\u30c9\u3059\u308b\u6a5f\u80fd\u3092\u5b9f\u88c5\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u6b21\u306b\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u3092RSS\u30d5\u30a3\u30fc\u30c9\u3059\u308b\u6a5f\u80fd\u3082\u5b9f\u88c5\u3057\u3001<br \/>\n\u4f59\u88d5\u304c\u3042\u308c\u3070\u30d5\u30a3\u30fc\u30c9\u306b\u8a8d\u8a3c\u30b9\u30ad\u30fc\u30e0\u3082\u8ffd\u52a0\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3092\u5236\u9650\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>REST API<\/h3>\n<p>\u591a\u304f\u306eWeb\u30b5\u30a4\u30c8\u306fAPI (Application Programmer Interface)\u3092<br \/>\n\u516c\u958b\u3057\u3066\u304a\u308a\u3001\u7b2c\u4e09\u8005\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u30ea\u30bd\u30fc\u30b9\u306eget\/post\/put\/delete\u304c\u884c\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3082\u3053\u306e\u3088\u3046\u306aREST API\u3092\u5b9f\u88c5\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u89e3\u6c7a\u306e\u30d2\u30f3\u30c8\u306f\u3001respond_to\u30d6\u30ed\u30c3\u30af\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u591a\u304f\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3059\u3002<br \/>\n\u3053\u306e\u30d6\u30ed\u30c3\u30af\u306fXML\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u305f\u3068\u304d\u306b\u5fdc\u7b54\u3057\u307e\u3059\u3002<br \/>\n\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306b\u306f\u5341\u5206\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u8a8d\u53ef\u3055\u308c\u305f\u30e6\u30fc\u30b6\u30fc\u306b\u306e\u307fAPI\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>\u691c\u7d22\u6a5f\u80fd<\/h3>\n<p>\u73fe\u5728\u306e\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u4e00\u89a7\u30da\u30fc\u30b8\u3092\u7aef\u304b\u3089\u63a2\u3059\u3001\u3082\u3057\u304f\u306f\u4ed6\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u30d5\u30a3\u30fc\u30c9\u3092\u8868\u793a\u3059\u308b\u4ee5\u5916\u306b\u4ed6\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u691c\u7d22\u3059\u308b\u624b\u6bb5\u304c\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u3053\u306e\u70b9\u3092\u5f37\u5316\u3059\u308b\u305f\u3081\u306b\u3001\u691c\u7d22\u6a5f\u80fd\u3092\u5b9f\u88c5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u7d9a\u3044\u3066\u3001\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u3092\u691c\u7d22\u3059\u308b\u6a5f\u80fd\u3082\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044<br \/>\n(\u30d2\u30f3\u30c8: \u307e\u305a\u306f\u81ea\u5206\u81ea\u8eab\u3067\u691c\u7d22\u6a5f\u80fd\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u63a2\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u96e3\u3057\u3051\u308c\u3070\u3001@budougumi0617 \u3055\u3093\u306e\u7c21\u5358\u306a\u691c\u7d22\u30d5\u30a9\u30fc\u30e0\u306e\u5b9f\u88c5\u4f8b\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044)\u3002<\/p>\n<h3>\u4ed6\u306e\u62e1\u5f35\u6a5f\u80fd<\/h3>\n<p>\u4e0a\u8a18\u306e\u4ed6\u306b\u3082\u3001\u300c\u3044\u3044\u306d\u6a5f\u80fd\u300d\u300c\u30b7\u30a7\u30a2\u6a5f\u80fd\u300d\u300cminitest\u306e\u4ee3\u308f\u308a\u306bRSpec\u3067\u66f8\u304d\u76f4\u3059\u300d\u300cerb\u306e\u4ee3\u308f\u308a\u306bHaml\u3067\u66f8\u304d\u76f4\u3059\u300d<br \/>\n\u300c\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092I18n\u3067\u65e5\u672c\u8a9e\u5316\u3059\u308b\u300d\u300c\u30aa\u30fc\u30c8\u30b3\u30f3\u30d7\u30ea\u30fc\u30c8\u6a5f\u80fd\u300d\u3068\u3044\u3063\u305f\u30a2\u30a4\u30c7\u30a2\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n<h3>14.4.3 \u672c\u7ae0\u306e\u307e\u3068\u3081<\/h3>\n<h4>1:has_many :through\u3092\u4f7f\u3046\u3068\u3001\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u95a2\u4fc2\u3092\u30e2\u30c7\u30ea\u30f3\u30b0\u3067\u304d\u308b<\/h4>\n<h4>2:has_many\u30e1\u30bd\u30c3\u30c9\u306b\u306f\u3001\u30af\u30e9\u30b9\u540d\u3084\u5916\u90e8\u30ad\u30fc\u306a\u3069\u3001\u3044\u304f\u3064\u3082\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u308b<\/h4>\n<h4>3:\u9069\u5207\u306a\u30af\u30e9\u30b9\u540d\u3068\u5916\u90e8\u30ad\u30fc\u3068\u4e00\u7dd2\u306b<br \/>\nhas_many\/has_many :through\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001<br \/>\n\u80fd\u52d5\u7684\u95a2\u4fc2 (\u30d5\u30a9\u30ed\u30fc\u3059\u308b) \u3084\u53d7\u52d5\u7684\u95a2\u4fc2 (\u30d5\u30a9\u30ed\u30fc\u3055\u308c\u308b)\u304c\u30e2\u30c7\u30ea\u30f3\u30b0\u3067\u304d\u305f<\/h4>\n<h4>4:\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u3001\u30cd\u30b9\u30c8\u3055\u305b\u3066\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b<\/h4>\n<h4>5:where\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3068\u3001<br \/>\n\u67d4\u8edf\u3067\u5f37\u529b\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u554f\u3044\u5408\u308f\u305b\u304c\u4f5c\u6210\u3067\u304d\u308b<\/h4>\n<h4>6:Rails\u306f (\u5fc5\u8981\u306b\u5fdc\u3058\u3066) \u4f4e\u7d1a\u306aSQL\u30af\u30a8\u30ea\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b<\/h4>\n<h4>7:\u672c\u66f8\u3067\u5b66\u3093\u3060\u3059\u3079\u3066\u3092\u99c6\u4f7f\u3059\u308b\u3053\u3068\u3067\u3001\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u30de\u30a4\u30af\u30ed\u30dd\u30b9\u30c8\u4e00\u89a7\u3092\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306b\u8868\u793a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u305f<\/h4>\n<p><strong>has_many through<\/strong><br \/>\n\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u6027\u3092\u5b9a\u7fa9\u3059\u308b\u95a2\u9023\u4ed8\u3051\u30e1\u30bd\u30c3\u30c9\u3002<\/p>\n<p><strong>source<\/strong><br \/>\nhas_many\u306b\u5bfe\u3057\u3066\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4e0e\u3048\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3002<br \/>\nsource\u30aa\u30d6\u30b7\u30e7\u30f3\u3067\u4e0e\u3048\u305f\u5024\u306f\u914d\u5217\u306e\u5143\u3092\u8868\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u5b9f\u969b\u306e\u914d\u5217\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u5909\u308f\u3089\u306a\u3044\u3002<\/p>\n<p><strong>collection<\/strong><br \/>\n\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8ffd\u52a0\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3002<br \/>\nid\u3092\u6307\u5b9a\u305b\u305a\u306b\u5168\u3066\u306e\u30e1\u30f3\u30d0\u30fc\u3092\u8868\u793a\u3057\u305f\u308a\u3067\u304d\u308b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u305d\u306e14.25\u304b\u3089\u7d9a\u304f 14.3 \u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9 \u6700\u5f8c\u306e\u96e3\u95a2\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306e\u5b9f\u88c5\u306b\u53d6\u308a\u304b\u304b\u308a\u307e\u3057\u3087\u3046\u3002 \u672c\u66f8\u306e\u4e2d\u3067\u3082\u6700\u3082\u9ad8\u5ea6\u306a\u3082\u306e\u3067\u3059\u3002\u5b8c\u5168\u306a\u30b9\u30c6\u30fc\u30bf\u30b9\u30d5\u30a3\u30fc\u30c9\u306f\u3001 13\u7ae0\u3067\u6271\u3063\u305f\u30d7\u30ed\u30c8\u30d5\u30a3\u30fc\u30c9\u3092\u30d9\u30fc\u30b9\u306b\u3057\u307e\u3059 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2764,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27,13],"tags":[],"class_list":["post-3114","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-note","category-rails"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=3114"}],"version-history":[{"count":9,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3114\/revisions"}],"predecessor-version":[{"id":4591,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3114\/revisions\/4591"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media\/2764"}],"wp:attachment":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=3114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=3114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=3114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}