{"version":"1.0","height":"190","published":"2013-09-01 13:10:34","type":"rich","image_url":null,"title":"rails4 \u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u5916\u90e8\u30ad\u30fc\u540d\u3092\u5909\u66f4","url":"https://ayaketan.hatenablog.com/entry/2013/09/01/131034","provider_url":"https://hatena.blog","width":"100%","provider_name":"Hatena Blog","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fayaketan.hatenablog.com%2Fentry%2F2013%2F09%2F01%2F131034\" title=\"rails4 \u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u5916\u90e8\u30ad\u30fc\u540d\u3092\u5909\u66f4 - ayaketan\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u52c9\u5f37\u65e5\u8a18\" 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"],"author_name":"ayaketan","blog_title":"ayaketan\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u52c9\u5f37\u65e5\u8a18","description":"\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u5916\u90e8\u30ad\u30fc\u3092\u5909\u66f4\u3057\u305f\u306e\u3067\u3001\u30e1\u30e2\u3002Users\u30c6\u30fc\u30d6\u30eb\u3068Sales\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u3068\u3059\u308b\u3002 Users\u30c6\u30fc\u30d6\u30eb\u306eid\u3068Sales\u30c6\u30fc\u30d6\u30eb\u306ecustomer_id\u3092\u7d10\u3065\u3051\u305f\u304b\u3063\u305f\u3002 class User < ActiveRecord::Base has_many :sales, :foreign_key => \"customer_id\" end class Sale < ActiveRecord::Base belongs_to :user end \u53c2\u7167\uff1a ruby/rails/RailsGuides\u3092\u3086\u3063\u304f\u308a\u548c\u8a33\u3057\u3066\u307f\u305f\u3088/Active Record Associations - \u682a\u5f0f\u4f1a\u2026","blog_url":"https://ayaketan.hatenablog.com/","author_url":"https://blog.hatena.ne.jp/ayaketan/"}