test/app/controllers/importer_controller.rb
# Returns the id for the given version or raises RecordNotFound.
# Implements a cache of version ids based on version name
# If add_versions is true and a valid name is given,
# will create a new version and save it when it doesn't exist yet.
Returns the id for the given version or raises RecordNotFound.
Implements a cache of version ids based on version name
If add_versions is true and a valid name is given,
will create a new version and save it when it doesn't exist yet.
Returns the id for the given version or raises RecordNotFound . Implements a cache of version ids based on version name If add_versions is true and a valid name is given will create a new version and save it when it doesn ' t exist yet .
def version_id_for_name!(project,name,add_versions)
    if !@version_id_by_name.has_key?(name)
      version = Version.find_by_project_id_and_name(project.id, name)
      if !version
        if name && (name.length > 0) && add_versions
          version = project.versions.build(:name=>name)
          version.save
        else
          @unfound_class = "Version"
          @unfound_key = name
          raise ActiveRecord::RecordNotFound, "No version named #{name}"
        end
      end
      @version_id_by_name[name] = version.id
    end
    @version_id_by_name[name]
  end
def version_id_for_name! ( project , name , add_versions ) if ! @version_id_by_name . has_key? ( name ) version = Version . find_by_project_id_and_name ( project . id , name ) if ! version if name && ( name . length > 0 ) && add_versions version = project . versions . build ( :name => name ) version . save else @unfound_class = "Version" @unfound_key = name raise ActiveRecord :: RecordNotFound , "No version named #{name}" end end @version_id_by_name [ name ] = version . id end @version_id_by_name [ name ] end
Returns the id for the given version or raises RecordNotFound.
Returns the id for the given version or raises RecordNotFound .
project
<not_specific>
name
<not_specific>
add_versions
<not_specific>