kjdelys PRO
Joined 4/26/2021
kjdelys PRO said about 3 years ago on Active Storage Validators :
Hey,
file_size_validator won't work with has_many_attached.

You need to update it to something like

if value.class == ActiveStorage::Attached::Many
  return if value.all? { |file| file.blob.byte_size < options[:less_than].megabytes }
else
  return if value.blob.byte_size < options[:less_than].megabytes
end

kjdelys PRO said about 2 years ago :
Hey David,
I tried that. Not still working. The images are still broken.

kjdelys PRO said about 2 years ago :
It seems it works now. To be honnest i don't know what changed

kjdelys PRO said almost 2 years ago :
Hey Thanks   David Kimura  
i have that. still not working. it keeps raising the same error with 
Tempfile.new

kjdelys PRO said almost 2 years ago :
yeah.


require 'fileutils'

unless Rails.env.development?
  # force the whole app to use its own tmpdir
  FileUtils.mkdir_p(Rails.root.join('tmp'))
  ENV['TMPDIR'] = Rails.root.join('tmp').to_s
end


in initializer fix everything