美好的一天。
我正在努力使用ActiveAdmin& amp;添加多个上传到我的rails 5 app Carrierwave。
截至目前,我收到以下错误:
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
你能帮我理解我在这里做错了吗?
答案 0 :(得分:3)
文档中很容易错过's'。检查模型中的安装。对于多个文件,您需要mount_uploaders
(多个)而不是mount_uploader
(单数)。