【问题标题】:ActiveAdmin + CarrierWave & Multiple Uploads: no implicit conversion of nil into StringActiveAdmin + CarrierWave 和多次上传:没有将 nil 隐式转换为字符串
【发布时间】:2017-03-22 17:49:29
【问题描述】:

美好的一天。

我正在使用 ActiveAdmin 和 Carrierwave 向我的 rails 5 应用程序添加多个上传。

截至目前,我收到以下错误:

no implicit conversion of nil into String

def workfile_path(for_file=original_filename)
   File.join(CarrierWave.tmp_path, @cache_id, version_name.to_s, for_file)
end

这是我设置文件的方式。

# admin/photo.rb  
permit_params :description, {image: []}, :taken, :image_cache, :tag_list, :title

form html: { multipart: true } do |f|
 f.inputs "New Image" do
   f.input :title, placeholder: "Drinking Coffee", hint: "Reference title for photo.", required: true
   f.input :image, as: :file, id: "preview_this_image",
                            input_html: {
                              multiple: true,
                            }
   f.input :taken, label: "Taken on:", as: :date_select, hint: "When was the photo taken?"
 end
 f.actions
end

#schema
create_table "photos", force: :cascade do |t|
  t.string   "description"
  t.datetime "taken"
  t.datetime "created_at",  null: false
  t.datetime "updated_at",  null: false
  t.string   "title"
  t.json     "image"
end

你能帮我理解我在这里做错了什么吗?

【问题讨论】:

    标签: ruby-on-rails activeadmin carrierwave


    【解决方案1】:

    文档中有一个容易漏掉的“s”。检查模型中的安装。对于多个文件,您需要mount_uploaders(多个)而不是mount_uploader(单数)。

    【讨论】:

    • 就是这样!呃 - 这么小的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    相关资源
    最近更新 更多