Update discussion counts on archive

For issue #1494 

I didn't see any attempt at counting motions per group other than a DB column, so left that for another pull request.

Is there a concept of unarchiving? If so we'll want to increment the counter if a discussion comes back to life somehow.
Uhmm.. I see your point!

Well in that case I think the best thing to do would be to have
discussions.motion_count and group can just call sum on them. That's pretty
cheap.


On Sat, Jun 21, 2014 at 6:44 PM, James Kiesel <notifications@github.com>
wrote:

> In app/models/motion.rb:
>
> > @@ -37,6 +37,8 @@ class Motion < ActiveRecord::Base
> >
> >    after_initialize :set_default_closing_at
> >    after_create :fire_new_motion_event
> > +  after_create :increment_group_counter
>
> Ahah, maybe this will work:
>
> belongs_to :group, counter_cache: :motions_count
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/loomio/loomio/pull/1522/files#r14048595>.
>