app/controllers/taxa/names_controller.rb
# POST /pages/:taxon_id/names NOTE - this is currently only used to add common_names
POST /pages/:taxon_id/names NOTE - this is currently only used to add common_names
POST / pages / : taxon_id / names NOTE - this is currently only used to add common_names
def create
    if params[:commit_add_common_name]
      current_user.add_agent unless current_user.agent
      agent = current_user.agent
      language = Language.find(params[:name][:synonym][:language_id])
      synonym = @taxon_concept.add_common_name_synonym(params[:name][:string],
                agent: agent, language: language, vetted: Vetted.trusted)
      unless synonym.errors.blank?
        flash[:error] = I18n.t(:common_name_exists, name_string: params[:name][:string])
      else
        @taxon_concept.reindex_in_solr
        log_action(@taxon_concept, synonym, :add_common_name)
        expire_taxa([@taxon_concept.id])
      end
    end
    store_location :back
    redirect_back_or_default common_names_taxon_names_path(@taxon_concept)
  end
def create if params [ :commit_add_common_name ] current_user . add_agent unless current_user . agent agent = current_user . agent language = Language . find ( params [ :name ] [ :synonym ] [ :language_id ] ) synonym = @taxon_concept . add_common_name_synonym ( params [ :name ] [ :string ] , agent : agent , language : language , vetted : Vetted . trusted ) unless synonym . errors . blank? flash [ :error ] = I18n . t ( :common_name_exists , name_string : params [ :name ] [ :string ] ) else @taxon_concept . reindex_in_solr log_action ( @taxon_concept , synonym , :add_common_name ) expire_taxa ( [ @taxon_concept . id ] ) end end store_location :back redirect_back_or_default common_names_taxon_names_path ( @taxon_concept ) end
POST /pages/:taxon_id/names NOTE - this is currently only used to add common_names
POST / pages / : taxon_id / names NOTE - this is currently only used to add common_names