我正在上传几张图片(来自http://localhost:3000/choices/new
),它们工作正常,但是,我试图重定向回:http://localhost:3000/choices
保存后。
这是我的控制器:
#app/controllers/choices_controller.rb
def create
@choice = Choice.new(choice_params)
@choice.filename = params[:filename].titleize
if @choice.save
respond_to do |format|
format.html { redirect_to choices_path }
format.json { head :no_content }
end
end
end
在 Rails 控制台中,它输出:
Redirected to http://localhost:3000/choices
Completed 302 Found in 58ms (ActiveRecord: 52.8ms)
然而,“新”页面仍然是静态的。关于如何正确重定向此内容的任何想法,可能会显示“图片上传成功”的消息?
非常感谢!