ruby-on-rails – 主动管理多个文件/图像上传与回形针
发布时间:2020-12-16 22:35:47 所属栏目:百科 来源:网络整理
导读:我使用活动管理员,我需要上传图库很多图像.我该怎么做? 我的代码: class Gallery ActiveRecord::Base belongs_to :event has_many :images attr_accessible :name,:publish,:images,:image,:images_attributes accepts_nested_attributes_for :images,allo
我使用活动管理员,我需要上传图库很多图像.我该怎么做?
我的代码: class Gallery < ActiveRecord::Base belongs_to :event has_many :images attr_accessible :name,:publish,:images,:image,:images_attributes accepts_nested_attributes_for :images,allow_destroy: true validates :name,presence: true end class Image < ActiveRecord::Base belongs_to :gallery attr_accessible :url has_attached_file :url,:styles => { :medium => "300x300>",:thumb => "100x100>" } end ActiveAdmin.register Gallery do form html: { multipart: true } do |f| f.inputs do f.input :name f.input :images,as: :file,input_html: { multiple: true} end f.buttons end end 我有这个错误: Image(#70319146544460) expected,got ActionDispatch::Http::UploadedFile(#70319105893880) 解决方法
尝试这个:
ActiveAdmin.register Gallery do form multipart: true do |f| f.inputs do f.input :name f.has_many :images do |p| p.input :url end end f.actions end end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |