app/models/observation.rb
def update_identifications
    return true if @skip_identifications
    return true unless taxon_id_changed?
    owners_ident = identifications.where(:user_id => user_id).order("id asc").last
    
    # If there's a taxon we need to make sure the owner's ident agrees
    if taxon && (owners_ident.blank? || owners_ident.taxon_id != taxon.id)
      # If the owner doesn't have an identification for this obs, make one
      attrs = {:user => user, :taxon => taxon, :observation => self, :skip_observation => true}
      owners_ident = if new_record?
        self.identifications.build(attrs)
      else
        self.identifications.create(attrs)
      end
    elsif taxon.blank? && owners_ident && owners_ident.current?
      if identifications.where(:user_id => user_id).count > 1
        owners_ident.update_attributes(:current => false, :skip_observation => true)
      else
        owners_ident.skip_observation = true
        owners_ident.destroy
      end
    end
    
    update_stats(:skip_save => true)
    
    true
  end
#
# Adds, updates, or destroys the identification corresponding to the taxon
# the user selected.
#
Adds, updates, or destroys the identification corresponding to the taxon
the user selected.
Adds updates or destroys the identification corresponding to the taxon the user selected .
def update_identifications
    return true if @skip_identifications
    return true unless taxon_id_changed?
    owners_ident = identifications.where(:user_id => user_id).order("id asc").last
    if taxon && (owners_ident.blank? || owners_ident.taxon_id != taxon.id)
      attrs = {:user => user, :taxon => taxon, :observation => self, :skip_observation => true}
      owners_ident = if new_record?
        self.identifications.build(attrs)
      else
        self.identifications.create(attrs)
      end
    elsif taxon.blank? && owners_ident && owners_ident.current?
      if identifications.where(:user_id => user_id).count > 1
        owners_ident.update_attributes(:current => false, :skip_observation => true)
      else
        owners_ident.skip_observation = true
        owners_ident.destroy
      end
    end
    update_stats(:skip_save => true)
    true
  end
def update_identifications return true if @skip_identifications return true unless taxon_id_changed? owners_ident = identifications . where ( :user_id => user_id ) . order ( "id asc" ) . last if taxon && ( owners_ident . blank? || owners_ident . taxon_id != taxon . id ) attrs = { :user => user , :taxon => taxon , :observation => self , :skip_observation => true } owners_ident = if new_record? self . identifications . build ( attrs ) else self . identifications . create ( attrs ) end elsif taxon . blank? && owners_ident && owners_ident . current? if identifications . where ( :user_id => user_id ) . count > 1 owners_ident . update_attributes ( :current => false , :skip_observation => true ) else owners_ident . skip_observation = true owners_ident . destroy end end update_stats ( :skip_save => true ) true end
Adds, updates, or destroys the identification corresponding to the taxon
the user selected.
Adds updates or destroys the identification corresponding to the taxon the user selected .
# If there's a taxon we need to make sure the owner's ident agrees # If the owner doesn't have an identification for this obs, make one