{"url":"https://izumin.hateblo.jp/entry/2015/02/13/235900","image_url":null,"blog_title":"Augmented Usamimi","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fizumin.hateblo.jp%2Fentry%2F2015%2F02%2F13%2F235900\" title=\"\u3010Rails\u3011JOIN\u3059\u308bscope\u3092\u66f8\u304f - Augmented Usamimi\" 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","Ruby on Rails","RSpec"],"author_name":"izumin5210","title":"\u3010Rails\u3011JOIN\u3059\u308bscope\u3092\u66f8\u304f","provider_name":"Hatena Blog","author_url":"https://blog.hatena.ne.jp/izumin5210/","width":"100%","provider_url":"https://hatena.blog","version":"1.0","published":"2015-02-13 23:59:00","blog_url":"https://izumin.hateblo.jp/","height":"190","description":"\u540c\u4e00\u306eJOIN\u3092\u8907\u6570\u306escope\u3084\u30e1\u30bd\u30c3\u30c9\uff0c\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3067\u4f7f\u7528\u3059\u308b\u5834\u5408\uff0c \u305d\u308c\u81ea\u4f53\u3092scope\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3066\u304a\u304f\u3068\u3061\u3087\u3063\u3068DRY\u306b\u306a\u308b\uff0e scope :join_before_date_period, -> do before = Event.arel_table.alias('before_event') joins( arel_table.join(before, Arel::Nodes::OuterJoin) .on(before[:id].eq arel_table[:before_event_id]).join_sources ) end \u540c\u3058alias\u8cbc\u3063\u305farel_table\u3092\u4f7f\u2026"}