Rails + CarrierWave: NoMethodError: undefined method `name' for nil:NilClass

后端 未结 6 517
挽巷
挽巷 2021-01-18 02:19

I am using CarrierWave with Rails 3.1. I am getting the following error message when I submit the form (trying to upload an image):

Error Message:

Ac         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 02:52

    I experienced the some problem and the cause is (probably always) that the UploadedFile object has been sent to the attribute carrierwave was mounted on. The db adapter cannot serialize this object and will therefore throw this error.

    Make sure that:

    • the uploader has been properly mounted
    • you don't use write_attribute to write the uploaded file (which was the cause of my problem). Use the accessor instead: model.send('image=', params[:model][:image]). Uglier, but better.

提交回复
热议问题