samedi 7 novembre 2020

Need a block of ruby code explained - or at least what I need to do to look it up

I'm a programmer, but I don't know ruby and/or ruby on rails at all. All I need to do is skip this validation check - have it return true - or return whatever value it returns if the hash is unique. I can't find explanations for the use of : nor :on Can anyone either explain to me what is happening here, or tell me how I can look up the pertinent symbols/terms?

class Stl < ApplicationRecord
  before_validation :compute_hash
  validates_uniqueness_of :md5hash, :on => :create

  mount_uploader :file, StlUploader
  belongs_to :product


  def compute_hash
    self.md5hash = Digest::MD5.hexdigest(self.file.read)
  end

end

Aucun commentaire:

Enregistrer un commentaire