【发布时间】:2017-10-21 06:26:26
【问题描述】:
我正在尝试使用以下内容:
class PaymentsController < ApplicationController
def addproduct
(session[:products] ||= []) << params[:item]
redirect_to :back
end
end
我遇到了这个异常:
undefined method `back_url' for #<PaymentsController:0x007ff682c467a8>
为什么会这样?
【问题讨论】:
-
你在控制台得到
ActionController::RedirectBackError吗? -
在控制台中我得到了我写的异常。
-
@Lechucico:您使用的是哪个版本的 Rails?从 Rails 5 开始,它是
redirect_back,带有一个后备选项。 -
rails 5.1.1 版本
标签: ruby-on-rails ruby redirect