lib/config_scripts/seeds/seed_type.rb
# This method finds a record for our model class based on the unique seed
# identifier.
#
# @param [Array<String>] identifier
#   The identifier from the CSV file.
#
# @return [ActiveRecord::Base]
#   The record
This method finds a record for our model class based on the unique seed
identifier.
This method finds a record for our model class based on the unique seed identifier .
def record_for_seed_identifier(identifier)
        return nil if identifier.blank?
        records = self.all
        self.identifier_attributes.each_with_index do |attribute, index|
          if self.associations.has_key?(attribute)
            value = self.read_value_for_association(attribute, identifier)
            records = records.where("#{attribute}_id" => value.try(:id))
          else
            value = self.read_value_for_attribute(identifier.shift, attribute)
            records = records.where(attribute => value)
          end
        end
        records.first
      end
def record_for_seed_identifier ( identifier ) return nil if identifier . blank? records = self . all self . identifier_attributes . each_with_index do | attribute , index | if self . associations . has_key? ( attribute ) value = self . read_value_for_association ( attribute , identifier ) records = records . where ( "#{attribute}_id" => value . try ( :id ) ) else value = self . read_value_for_attribute ( identifier . shift , attribute ) records = records . where ( attribute => value ) end end records . first end
This method finds a record for our model class based on the unique seed
identifier.
This method finds a record for our model class based on the unique seed identifier .
None
ActiveRecord::Base
identifier
<not_specific>
<not_specific>
identifier The identifier from the CSV file.
identifier The identifier from the CSV file .