app/controllers/survey_respondents/tags_admin_controller.rb
# The start page, we start with a hash of the tag contexts and their associated tags
The start page, we start with a hash of the tag contexts and their associated tags
The start page we start with a hash of the tag contexts and their associated tags
def fix
    taggings = ActsAsTaggableOn::Tagging.where("taggable_type like 'SurveyRespondent'").
                  distinct(:context)
    tcs = Array.new
    taggings.each do |tagging|
      tcs << tagging.context
    end
    tcs.each do |context|
      responses = SurveyResponse.references(:survey_question).where({:survey_questions => {:tags_label => context}})
      responses.each do |response|
        tags = response.survey_respondent_detail.survey_respondent.tag_counts_on(context)
        new_tags = tags.collect {|tag| tag.name }
        response.response = new_tags.join(",")
        response.save
      end
    end
  end
def fix taggings = ActsAsTaggableOn :: Tagging . where ( "taggable_type like 'SurveyRespondent'" ) . distinct ( :context ) tcs = Array . new taggings . each do | tagging | tcs << tagging . context end tcs . each do | context | responses = SurveyResponse . references ( :survey_question ) . where ( { :survey_questions => { :tags_label => context } } ) responses . each do | response | tags = response . survey_respondent_detail . survey_respondent . tag_counts_on ( context ) new_tags = tags . collect { | tag | tag . name } response . response = new_tags . join ( "," ) response . save end end end
The start page, we start with a hash of the tag contexts and their associated tags
The start page we start with a hash of the tag contexts and their associated tags
# for each context get the set of tags (sorted), and add them to the collection for display on the page # go through all the respondents and fix the tags.... # respondents = SurveyRespondent.all # respondents.each do |respondent| # tcs.each do |context| # tags = respondent.tag_counts_on(context) # if (respondent.person) # respondent.person.set_tag_list_on(context, tags ) # respondent.person.save # end # end # end