0
그래서 여러 파일 업로드 설정을 위해 자전거 클립과 함께 Ryan Bates 중첩 모델 양식 railscast를 사용했습니다. 어떤 사람은 '첨부 파일'속성에 대량 할당 문제가 있고 스택에있는 친절한 사람들 중 일부가 내가 잘못한 부분을 지적 할 수 있는지 궁금해하고 있습니다. form.html.erb종이 클립을 통한 여러 번 업로드 대량 할당으로 인한 문제
Apartments.rb
has_many :attachments
accepts_nested_attributes_for :attachments
attr_accessible :title, :body, :bedrooms, :bathrooms, :rent, :security_deposit, :neighborhood, :intersection, :sqfeet, :attachments_attributes, :attachments
Attachment.rb
attr_accessible :caption, :apartment_id
belongs_to :apartment
has_attached_file :image
아파트
<%= f.simple_fields_for :attachments do |builder| %>
<%= render 'attachments_fields', f: builder %>
<% end %>
<%= f.file_field :attachments %><br />
,369 Atachment_fields.html.erb개
요청에 Params
{"utf8"=>"✓", "authenticity_token"=>"MruMcUX3k43JxHv9jJMLxxipf5By0cBsk2d+L6O0SL4=", "apartment"=>{"title"=>"", "bedrooms"=>"", "bathrooms"=>"", "rent"=>"", "security_deposit"=>"", "intersection"=>"", "body"=>"", "attachments_attributes"=>{"1378213436357"=>{"attachments"=>#<ActionDispatch::Http::UploadedFile:0x007fa089c546e0 @original_filename="Ixia.gif", @content_type="image/gif", @headers="Content-Disposition: form-data; name=\"apartment[attachments_attributes][1378213436357][attachments]\"; filename=\"Ixia.gif\"\r\nContent-Type: image/gif\r\n", @tempfile=#<Tempfile:/var/folders/7l/66jh7_ld5ng5cdhdslpxc0180000gn/T/RackMultipart20130903-15330-1jplpe6>>}}}, "neighborhood"=>"Albany Park", "commit"=>"Create Apartment", "action"=>"create", "controller"=>"apartments"}
많은 감사합니다!
좋은 주. 글쎄, 신선한 눈빛이 나를 좋게했다. – Raphi