app/models/assay.rb
#Associates and organism with the assay
#organism may be either an ID or Organism instance
#strain_id should be the id of the strain
#culture_growth should be the culture growth instance
Associates and organism with the assay
organism may be either an ID or Organism instance
strain_id should be the id of the strain
culture_growth should be the culture growth instance
Associates and organism with the assay organism may be either an ID or Organism instance strain_id should be the id of the strain culture_growth should be the culture growth instance
def associate_organism(organism,strain_id=nil,culture_growth_type=nil,tissue_and_cell_type_id="0",tissue_and_cell_type_title=nil)
    organism = Organism.find(organism) if organism.kind_of?(Numeric) || organism.kind_of?(String)
    strain=organism.strains.find_by_id(strain_id)
    assay_organism=AssayOrganism.new(:assay=>self,:organism=>organism,:culture_growth_type=>culture_growth_type,:strain=>strain)
    unless AssayOrganism.exists_for?(strain,organism,self,culture_growth_type)
      self.assay_organisms << assay_organism
    end
    tissue_and_cell_type=nil
    if !tissue_and_cell_type_title.blank?
      if ( tissue_and_cell_type_id =="0" )
        found = TissueAndCellType.where(:title => tissue_and_cell_type_title).first
        unless found
          tissue_and_cell_type = TissueAndCellType.create!(:title=> tissue_and_cell_type_title) if (!tissue_and_cell_type_title.nil? && tissue_and_cell_type_title!="")
        end
      else
        tissue_and_cell_type = TissueAndCellType.find_by_id(tissue_and_cell_type_id)
      end
    end
    assay_organism.tissue_and_cell_type = tissue_and_cell_type
  end
def associate_organism ( organism , strain_id = nil , culture_growth_type = nil , tissue_and_cell_type_id = "0" , tissue_and_cell_type_title = nil ) organism = Organism . find ( organism ) if organism . kind_of? ( Numeric ) || organism . kind_of? ( String ) strain = organism . strains . find_by_id ( strain_id ) assay_organism = AssayOrganism . new ( :assay => self , :organism => organism , :culture_growth_type => culture_growth_type , :strain => strain ) unless AssayOrganism . exists_for? ( strain , organism , self , culture_growth_type ) self . assay_organisms << assay_organism end tissue_and_cell_type = nil if ! tissue_and_cell_type_title . blank? if ( tissue_and_cell_type_id == "0" ) found = TissueAndCellType . where ( :title => tissue_and_cell_type_title ) . first unless found tissue_and_cell_type = TissueAndCellType . create! ( :title => tissue_and_cell_type_title ) if ( ! tissue_and_cell_type_title . nil? && tissue_and_cell_type_title != "" ) end else tissue_and_cell_type = TissueAndCellType . find_by_id ( tissue_and_cell_type_id ) end end assay_organism . tissue_and_cell_type = tissue_and_cell_type end
Associates and organism with the assay
organism may be either an ID or Organism instance
strain_id should be the id of the strain
culture_growth should be the culture growth instance
Associates and organism with the assay organism may be either an ID or Organism instance strain_id should be the id of the strain culture_growth should be the culture growth instance
organism
strain_id
culture_growth_type
tissue_and_cell_type_id
tissue_and_cell_type_title