AmyAdamsIsBae AmyAdamsIsBae - 1 year ago 77
Ruby Question

TypeError no implicit conversion of PicUploader into String

I'm using

to generate excel sheets that contain the info that is in my User entity. the problem arises when i try to put an image in the excel sheet. I'm using
carrierwave 0.11.2
and I've made sure that I have set it up correctly, I have the string column
that holds the image, I have the uploader
and it's mounted to User. the carrierwave implementation works fine, and the picture shows in the user's "show" page but when i try to follow the axlsx example to put the image in the sheet as such

img = File.expand_path(@user.profile_pic, __FILE__)
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|

I get the TypeError
no implicit conversion of PicUploader into String

Any idea what might be causing this ?

Answer Source

It is saying that expand_path expects a string, not a PicUploader class as parameter. Try

img = File.expand_path(@user.profile_pic.current_path, __FILE__)