Class: Vote

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/vote.rb

Instance Method Summary collapse

Instance Method Details

#update_poll_votes_countObject


13
14
15
16
17
# File 'app/models/vote.rb', line 13

def update_poll_votes_count
  votes_count = Choice.where(:poll_id => self.poll_id).sum(:votes_count)
  self.poll.votes_count = votes_count
  self.poll.save!
end