I just added a patch to lighthouse that adds query attribute methods
to associations. This makes associations behave more like any other
attribute -
class Post < ActiveRecord::Base
has_many :comments
end
Post.new.comments? # => false
It adds query attribute methods to has_one (and through), has_many
(and through), belongs_to (works with polymorphic) and
has_and_belongs_to_many.
If that looks interesting / worthwhile, you can plus one it at:
Jeff Dean