app/models/record.rb
# Takes the recommendations from the prior record and copies them into the existing record.
# Note: the recommendations include color,feedback, last_updated, opinion, recommendation field, discussions
Takes the recommendations from the prior record and copies them into the existing record.
Note: the recommendations include color,feedback, last_updated, opinion, recommendation field, discussions
Takes the recommendations from the prior record and copies them into the existing record . Note : the recommendations include color feedback last_updated opinion recommendation field discussions
def copy_recommendations(prior_record)
    return 0, 0 if prior_record.nil?
    current = get_column_record_data_map(self)
    prior = get_column_record_data_map(prior_record)
    copied = 0
    not_copied = 0
    current.keys.each do |column_name|
      if prior[column_name].nil?
        not_copied += 1
        next
      end
      current_value = current[column_name].value
      prior_value = prior[column_name].value
      unless current_value.eql? prior_value
        not_copied += 1
        next
      end
      current_data = current[column_name]
      prior_data = prior[column_name]
      current_data.color = prior_data.color
      current_data.feedback = prior_data.feedback
      current_data.last_updated = prior_data.last_updated
      current_data.opinion = prior_data.opinion
      current_data.recommendation = prior_data.recommendation
      current_data.save
      copied += 1
    end
    copy_recommendations_date = Time.now.strftime("%m/%d/%Y at %I:%M%p")
    self.copy_recommendations_note = "Copied recommendations from revision #{prior_record.revision_id} on #{copy_recommendations_date}"
    save
    [copied, not_copied]
  end
def copy_recommendations ( prior_record ) return 0 , 0 if prior_record . nil? current = get_column_record_data_map ( self ) prior = get_column_record_data_map ( prior_record ) copied = 0 not_copied = 0 current . keys . each do | column_name | if prior [ column_name ] . nil? not_copied += 1 next end current_value = current [ column_name ] . value prior_value = prior [ column_name ] . value unless current_value . eql? prior_value not_copied += 1 next end current_data = current [ column_name ] prior_data = prior [ column_name ] current_data . color = prior_data . color current_data . feedback = prior_data . feedback current_data . last_updated = prior_data . last_updated current_data . opinion = prior_data . opinion current_data . recommendation = prior_data . recommendation current_data . save copied += 1 end copy_recommendations_date = Time . now . strftime ( "%m/%d/%Y at %I:%M%p" ) self . copy_recommendations_note = "Copied recommendations from revision #{prior_record.revision_id} on #{copy_recommendations_date}" save [ copied , not_copied ] end
Takes the recommendations from the prior record and copies them into the existing record.
Takes the recommendations from the prior record and copies them into the existing record .
prior_record
<not_specific>