15

I'm using Carrierwave to handle image uploads, but I'm not using a form, instead I use local files in the server.

How can I make this work?

@user = User.first
image_path = "/tmp/pic-s7b28.jpg"

@user.image = image_path
@user.save!
CodeOverload
  • 47,274
  • 54
  • 131
  • 219
  • If you are using local files, how is that a file upload? I'm assuming that you want to do image manipulation through carrierwave? – AlexBrand Apr 22 '13 at 00:26

1 Answers1

28
@user = User.first
image_path = "/tmp/pic-s7b28.jpg"

@user.image = File.open(image_path)
@user.save!

You can check examples in the carrierwave readme

ole
  • 5,166
  • 5
  • 29
  • 57