Guest User

Untitled

a guest
Jul 20th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. ## question.rb
  2.  
  3. class Question < ActiveRecord::Base
  4. def self.calculate_popular
  5. all(:conditions => { :counted => false }).each do |question|
  6. iq = IndexQuestion.find_or_create_by_question({ :question => question.question })
  7. iq.increment! :count
  8. question.update_attribute :counted, true
  9. end
  10. end
  11. end
Add Comment
Please, Sign In to add comment