<%= semantic_form_for(@image, :url => { :action => "create_friend_upload" }, :html => {:multipart => true}) do |f| %>
<%= f.inputs do %>
<%= f.input :image, :input_html => {:multiple => true}, name: "gallery[image]" %>
<%= f.hidden_field :friend_upload, :value => true %>
<%= f.hidden_field :user_id %>
<%= f.hidden_field :friend_uploader, :value => current_user.name %>
<% end %>
<%= f.buttons do %>
<%= f.commit_button :button_html => {:class => "primary"} %>
<% end %>
<% end %>
문제는 Carrierwave에서 처리 할 수없는 배열을 계속 제출한다는 것입니다. 단지 name=\"gallery[image]\"
대신에 name=\"gallery[image][]\"
을 계속 말합니다. (아래 참조). 그 때문에 오류 메시지 can't convert nil into String
도 계속 표시됩니다.Carrierwave 및 JQuery 파일 업로드를 사용한 다중 파일 업로드
@headers="Content-Disposition: form-data; name=\"gallery[image][]\"; filename=\"VW 3.jpeg\"\r\nContent-Type: image/jpeg\r\n",
누구나 이것을 해결하는 방법을 알고 계십니까? 감사!
업데이트 : 나뿐만 아니라 JQuery와 라이언의 railscasts 비디오를 참조했다
는, 이것에 대한 자신의 수정 나를 위해 작동하지 않았다.
Gallery.rb
class Gallery < ActiveRecord::Base
attr_accessible :image, :name, :friend_upload,
mount_uploader :image, GalleryUploader
end
갤러리 컨트롤러
def friend_upload
@image = Gallery.new
end
def create_friend_upload
@image = Gallery.create(params[:gallery])
end
당신이 우리에게 갤러리 모델 선언을 보여줄 수
simple form
를 사용하여 일을 그게 전부? –@ D3mon-1stVFW, 갤러리의 모델 및 컨트롤러로 질문을 업데이트했습니다. 감사. – noob
http://pjambet.github.com/blog/direct-upload-to-s3/ 여기에 설명 된대로 carrierwave를 우회하여 s3에 파일을 직접 업로드 할 수 있습니다.이 예는 하나의 파일이지만 한 파일 만 사용할 수 있습니다. 파일 입력 여러, 그것은 잘 작동합니다. – pjam