我正在使用capybara 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
运行rails 3.2.13
capybara 2.1.0
默认rack_test驱动程序
答案 0 :(得分:0)
我的形式错字。
我有mulitpart: true
而不是multipart: true
。注意多部分的拼写错误。