app/models/taxon.rb
def threatened_in_place?(place)
    return false if place.blank?
    place_id = place.is_a?(Place) ? place.id : place
    place = Place.find_by_id(place_id) unless place.is_a?(Place)
    cs = if association(:conservation_statuses).loaded?
      conservation_statuses.detect{|cs| ([nil, place.ancestry.to_s.split("/")].flatten.include? cs.place_id.to_s) && cs.iucn.to_i > IUCN_LEAST_CONCERN}
    else
      conservation_statuses.where("place_id::text IN (#{ListedTaxon.place_ancestor_ids_sql(place_id)}) OR place_id IS NULL").where("iucn > ?", IUCN_LEAST_CONCERN).first
    end
    return !cs.nil?
  end
# Sometimes you don't want to make a new taxon name with a taxon, like when
# you're saving a new taxon name with a new associated taxon. Hence, this.
Sometimes you don't want to make a new taxon name with a taxon, like when
you're saving a new taxon name with a new associated taxon. Hence, this.
Sometimes you don ' t want to make a new taxon name with a taxon like when you ' re saving a new taxon name with a new associated taxon . Hence this .
def threatened_in_place?(place)
    return false if place.blank?
    place_id = place.is_a?(Place) ? place.id : place
    place = Place.find_by_id(place_id) unless place.is_a?(Place)
    cs = if association(:conservation_statuses).loaded?
      conservation_statuses.detect{|cs| ([nil, place.ancestry.to_s.split("/")].flatten.include? cs.place_id.to_s) && cs.iucn.to_i > IUCN_LEAST_CONCERN}
    else
      conservation_statuses.where("place_id::text IN (#{ListedTaxon.place_ancestor_ids_sql(place_id)}) OR place_id IS NULL").where("iucn > ?", IUCN_LEAST_CONCERN).first
    end
    return !cs.nil?
  end
def threatened_in_place? ( place ) return false if place . blank? place_id = place . is_a? ( Place ) ? place . id : place place = Place . find_by_id ( place_id ) unless place . is_a? ( Place ) cs = if association ( :conservation_statuses ) . loaded? conservation_statuses . detect { | cs | ( [ nil , place . ancestry . to_s . split ( "/" ) ] . flatten . include? cs . place_id . to_s ) && cs . iucn . to_i > IUCN_LEAST_CONCERN } else conservation_statuses . where ( "place_id::text IN (#{ListedTaxon.place_ancestor_ids_sql(place_id)}) OR place_id IS NULL" ) . where ( "iucn > ?" , IUCN_LEAST_CONCERN ) . first end return ! cs . nil? end
Sometimes you don't want to make a new taxon name with a taxon, like when
you're saving a new taxon name with a new associated taxon.
Sometimes you don ' t want to make a new taxon name with a taxon like when you ' re saving a new taxon name with a new associated taxon .
place