if File.exist?
“#{RAILS_ROOT}/public/images/#{property.id}/middle/#{image.name}”
File.unlink
“#{RAILS_ROOT}/public/images/#{property.id}/middle/#{image.name}”
end
why it does not work ?
error
No such file or directory -
script/…/config/…/public/images/144/middle/cfa9a31932bea2904485b56294764a6b.jpg
error
No such file or directory -
script/…/config/…/public/images/144/middle/cfa9a31932bea2904485b56294764a6b.jpg
Looks ok to me. But to avoid spelling errors I’d store the name in a
variable like
f = File.join RAILS_ROOT, “public”, “images”, property.id, “middle”,
image.name
File.unlink f if File.exists? f
HTH
Kind regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.