AmyAdamsIsBae
AmyAdamsIsBae

Reputation: 41

TypeError no implicit conversion of PicUploader into String

I'm using axlsx-rails 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 profile_pic that holds the image, I have the uploader PicUploader 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|
        image.width=420
        image.height=669
    end

I get the TypeError no implicit conversion of PicUploader into String
Any idea what might be causing this ?

Upvotes: 0

Views: 924

Answers (1)

Ursus
Ursus

Reputation: 30056

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__)

Upvotes: 1

Related Questions