Skip to content

Instantly share code, notes, and snippets.

@janjiss
Created July 11, 2011 14:07
Show Gist options
  • Save janjiss/1075915 to your computer and use it in GitHub Desktop.
Save janjiss/1075915 to your computer and use it in GitHub Desktop.
Does not set to true even if question count is more than progress
class Tracker < ActiveRecord::Base
attr_accessible :survey_id, :respondent_id, :progress, :completed
belongs_to :survey
after_save :set_completed?
#set tracker.completed to true if all questions are answered
def set_completed?
if progress >= survey.questions.count
completed = true
end
end
end
#Does not set to true even if question count is more than progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment