【发布时间】:2014-04-24 22:50:38
【问题描述】:
我正在使用dropzone-rails 将dropzone 添加到我的Rails 应用程序中。我正在使用 CarrierWave 进行图像上传,没有 Dropzone 也可以正常工作。
当我将图像拖放到 dropzone 表单时出现错误。该表单位于我的“Canvas”模型的编辑页面上。
表单html
<%= form_for(@canvas, :html => { :class => 'dropzone', :id => 'awesomeDropzone' }) do |f| %>
<%= f.file_field :image %>
<%= f.submit %>
<% end %>
Dropzone JS 调用
Dropzone.options.awesomeDropzone = {
paramName: "canvas[image]", // The name that will be used to transfer the file
clickable: false
};
控制台错误:
GET http://localhost:3000/canvases/21/edit 500 (Internal Server Error)
canvases_controller.rb
def edit
@canvas = Canvas.find(params[:id])
end
def update
@canvas = Canvas.find(params[:id])
if @canvas.update_attributes(update_params)
redirect_to edit_canvas_path(@canvas)
else
render :edit
end
end
canvas.rb
mount_uploader :image, ImageUploader
【问题讨论】:
-
开启调试 (
config.consider_all_requests_local = true) 并查看实际错误和堆栈跟踪。 -
如何开启调试?我该怎么处理你写的那行代码?
-
如果您正在运行您的 Rails 应用程序并将
RAILS_ENV设置为开发,这是默认设置,您将看到错误和堆栈跟踪输出。如果您在不同的环境(特别是生产环境)中运行,默认情况下您不会看到错误。您可以调整相关config/environments/____.rb文件中的设置或更改您正在启动的环境。由于这是本地主机,您可能只想在开发模式下运行。 -
您的日志中应该有完整的跟踪;默认情况下,地址为
./log/#{environment}.log。 -
我用日志链接更新了问题....我认为。
标签: javascript ruby-on-rails dropzone.js