我尝试将JQuery文件上传添加到产品模型以添加图片。 我的edit.html.erb
...
<%= file_field_tag "fileupload",
multiple: "",
"data-url" =>
"#{add_image_admin_products_path(product_id: @product.id)}" %>
它生成此输入:
<input data-url="/admin/products/add_image?product_id=2" id="fileupload" multiple="multiple" name="fileupload" type="file">
但是当添加文件操作时,我得到错误:
Error 404
ActiveRecord::RecordNotFound in Admin::ProductsController#update.
EDITED
的routes.rb
namespace :admin do
resources :products do
collection do
post 'add_image'
post 'destroy_image'
end
end
end
product_controller中的和add_image操作:
def add_image
render :json => {:Result => "Ok"}
end