pimbongaerts / mesophotic

Ruby on Rails application to host scientific information on mesophotic coral ecosystems
http://www.mesophotic.org
MIT License
1 stars 3 forks source link

open circuit tag #62

Closed veronicar239 closed 5 years ago

veronicar239 commented 5 years ago

@pimbongaerts For purpose of stats page:

This will be used to differentiate between 'Diving - open circuit' and 'Diving - rebreather' tags for the platform types in the summary statistics page.

pimbongaerts commented 5 years ago

This is a good suggestion. I replaced associations to platform IDs 3 (Diving - Technical...) and 6 (Diving - Regular...) with an association to ID 1 (Diving - unspecified) with the code below. And then renamed that category (ID 1) to "SCUBA (open-circuit or unspecified), and the rebreather category (ID 4) to "Rebreather" (for now). Platform IDs 3 and 6 are removed.

    [3,6].each do |i|
        Platform.find(i).publications.each do |publication|
            puts "Updating #{publication.id}:#{publication.title}"
            # Delete association
            association_to_be_deleted = publication.platforms.find(i)
            publication.platforms.delete(association_to_be_deleted)
            # Replace with new association
            publication.platforms << Platform.find(1)
        end
    end