我使用 jQuery fileupload 插件上传多张图片。我将插件设置为:
$(function(){
$('#fileupload').fileupload({
url: "/polls",
dataType: "html"
});
})
PollsController(简而言之):
def new
authenticate
@poll = Poll.new
respond_to do |format|
format.html
end
end
def create
@poll.nil? ? @poll = Poll.create(params[:poll]) : @poll.update_attributes(params[:poll])
if @poll.errors.full_messages.empty?
respond_to do |format|
format.html{ redirect_to @poll }
end
else
flash[:"alert-error"] = @poll.errors.full_messages
respond_to do |format|
format.html{ redirect_to '/polls/new' }
end
end
end
我正在测试验证,所以我在提交表单后得到:
...
(0.3ms) BEGIN
(0.3ms) ROLLBACK
Redirected to http://localhost:3000/polls/new
Completed 302 Found in 644ms (ActiveRecord: 1.1ms)
Started GET "/polls/new" for 127.0.0.1 at 2012-11-20 16:27:31 -0800
Processing by PollsController#new as HTML
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 18 LIMIT 1
Rendered polls/_template.haml (0.1ms)
Rendered polls/_jQuery_fileupload_plugin.haml (5.9ms)
Rendered polls/new.haml within layouts/application (14.3ms)
Rendered sessions/_signin.haml (3.9ms)
Rendered layouts/_header.haml (5.3ms)
Rendered layouts/_footer.haml (0.6ms)
Completed 200 OK in 42ms (Views: 38.0ms | ActiveRecord: 0.6ms)
但是页面实际上并没有重新加载。为什么会这样?
谢谢