Skip to content

Instantly share code, notes, and snippets.

View hoenth's full-sized avatar

Tom Hoen hoenth

  • NetworkForGood
  • Baltimore
View GitHub Profile
@hoenth
hoenth / gist:960c9c00ae8acc2e88da
Created April 15, 2015 12:22
Cache file validator
class VerifyCachedFileValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if carrierwave_file_lost?(value.cache_dir, value.cache_name)
record.send("remove_#{attribute}!")
record.errors[attribute] << "We encountered an error when trying to upload your #{attribute}. Please select it again."
end
end
private