k0kubun/activerecord-has_count — pull request #6 by k0kubun (2014-11-22 12:17:12+00:00)
Title: Change API

## Background
```ruby
class Tweet < ActiveRecord::Base
has_many :replies, class_name: 'Tweet', foreign_key: :in_reply_to_tweet_id
has_count :replies, class_name: 'Tweet', foreign_key: :in_reply_to_tweet_id
end
```

Because ActiveRecord association is under active develpoment, it would be hard to maintain a compatibility if I had overridden `has_many` association. So I designed this gem not to override `has_many` association.

But `has_count` association depends on `has_many` association existence and they should have the same options. Thus the current way to define `has_count` association is too lengthy.

## New API
```ruby
class Tweet < ActiveRecord::Base
has_many :replies, eager_counter: true, class_name: 'Tweet', foreign_key: :in_reply_to_tweet_id
end
```

New version will provide `:eager_counter` option, which is similar to `:counter_cache` option. The option will define `EagerCounter` association named `:replies_count`, and you can change association name if symbol is given instead of `true`.

So I'll do the API migration and rename gem to `activerecord-eager_counter`.