lib/surveyor_gui/models/survey_section_methods.rb
#don't let a survey be deleted or changed if responses have been submitted
#to ensure data integrity
don't let a survey be deleted or changed if responses have been submitted
to ensure data integrity
don ' t let a survey be deleted or changed if responses have been submitted to ensure data integrity
def no_responses
        if self.id && self.survey
          self.survey.response_sets.where('test_data = ?',true).each {|r| r.destroy}
        end
        if self.survey && !survey.template && survey.response_sets.count>0
          errors.add(:base, I18n.t('surveyor_gui.survey_sections.no_responses.has_responses') )
          return false
        end
      end
def no_responses if self . id && self . survey self . survey . response_sets . where ( 'test_data = ?' , true ) . each { | r | r . destroy } end if self . survey && ! survey . template && survey . response_sets . count > 0 errors . add ( :base , I18n . t ( 'surveyor_gui.survey_sections.no_responses.has_responses' ) ) return false end end
don't let a survey be deleted or changed if responses have been submitted
to ensure data integrity
don ' t let a survey be deleted or changed if responses have been submitted to ensure data integrity
#this will be a problem if two people are editing the survey at the same time and do a survey preview - highly unlikely though.