From dc764fcc348d562376add26ff8ef5173946b575b Mon Sep 17 00:00:00 2001 From: Jared Armstrong and Neeraj Singh Date: Wed, 10 Apr 2013 08:34:47 -0400 Subject: While merging relations preserve context for joins Fixes #3002. Also see #5494. ``` class Comment < ActiveRecord::Base belongs_to :post end class Author < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :author has_many :comments end ``` `Comment.joins(:post).merge(Post.joins(:author).merge(Author.where(:name => "Joe Blogs"))).all` would fail with `ActiveRecord::ConfigurationError: Association named 'author' was not found on Comment`. It is failing because `all` is being called on relation which looks like this after all the merging: `{:joins=>[:post, :author], :where=>[#