1
我正在使用水豚2.1.0並有一個形式multiple: true
(允許我上傳多個文件)。該網站在瀏覽器中正常工作,但水豚有一個問題,因爲當我將該字段留空時,該字段正在提交內容""
而不是nil
。然後我從Paperclip得到一個關於""
是一個無效文件名的錯誤(有道理,沒有名爲""
的文件)。多重水豚形式:真正發送錯誤的值
這裏的形式:
= simple_form_for([@site, @zone], mulitpart: true) do |f|
= f.error_notification
.form-inputs
= f.input :site_id
= f.input :default_state
= file_field_tag "zone_shapefiles_asset", multiple: true, name: "zone[shapefiles_attributes][][asset]"
= label_tag "X"
= text_field_tag 'x_coords[]', nil, id: "x_coords_1"
= label_tag "Y"
= text_field_tag 'y_coords[]', nil, id: "y_coords_1"
= label_tag "X"
= text_field_tag 'x_coords[]', nil, id: "x_coords_2"
= label_tag "Y"
= text_field_tag 'y_coords[]', nil, id: "y_coords_2"
= label_tag "X"
= text_field_tag 'x_coords[]', nil, id: "x_coords_3"
= label_tag "Y"
= text_field_tag 'y_coords[]', nil, id: "y_coords_3"
= label_tag "X"
= text_field_tag 'x_coords[]', nil, id: "x_coords_4"
= label_tag "Y"
= text_field_tag 'y_coords[]', nil, id: "y_coords_4"
= link_to "Add Point", "#", id: "add_point", data: { fields: label_tags.gsub("\"", "'") }
.form-actions
= f.button :submit
和錯誤:
Paperclip::AdapterRegistry::NoHandlerError: No handler found for ""
./spec/features/zones_spec.rb:50:in `block (6 levels) in <top (required)>'
從這個規格:
it "can create region for zone" do
fill_in "x_coords_1", with: 0
fill_in "y_coords_1", with: 0
fill_in "x_coords_2", with: 10
fill_in "y_coords_2", with: 0
fill_in "x_coords_3", with: 10
fill_in "y_coords_3", with: 10
fill_in "x_coords_4", with: 0
fill_in "y_coords_4", with: 10
click_button "Create Zone"
page.should have_content "Zone was successfully created
end
運行軌道3.2.13
水豚2.1.0
默認rack_test司機
你使用什麼版本的水豚,以及哪個驅動程序? – georgebrock
更新了問題。水豚2.1.0,默認的rack_test驅動 –