Is is possible in Rails > 3.2 to add conditions to the join statement generated by the includes
method?
Let\'s say I have two models, Person and Note. E
Same was discussed in Japanese stackoverflow. Quite hacky, but following seems to work, at least on rails 5.
Person.eager_load(:notes).joins("AND notes.important = 't'")
One important aspect is that by this way, you can write arbitrary join condition. Down side is that you cannot use placeholder so you need to be careful when using params as the join condition.
https://ja.stackoverflow.com/q/22812/754