Today, i have a problem, with other people, it might a silly problem, but i.
I got 2 models, A and B, A has_many B, B belongs_to A. I want to find all of records of A model that these record have no associated record B. This is my scope, my solution:
Class A
scope :free_a, -> { where(includes(:b).where(bs: {a_id: nil}) }
It's really interesting for me. :)