Closed lostapathy closed 6 years ago
Hi! Thank you @lostapathy.
I've merged this, so left outer joins will be the default behaviour, and I also added the ability to configure:
# Per method
Author.all.include_post_count(join_type: :joins) # old behaviour
# Per model
class Author < ApplicationRecord
has_many :posts
can_count :posts, join_type: :joins
end
# global configuration
AssociationCount.configure do |config|
config.distinct = false
config.join_type = :joins # or left_outer_joins
end
Thanks for merging this! Glad to have found this gem, it's been a big hel.
This users left_outer_joins instead of joins so that associations with zero associated records are included in the results.
Resolves https://github.com/trialbee/association_count/issues/6