当我检查我的错误消息是否正常工作时,我注意到我的重定向转到/businesses
而不是/businesses/new
在它 POST(create
操作)之后。/businesses/new
我正在使用常规的 RESTFUL 路由,但是当它们出现错误时,我需要它返回到POST。我怎样才能做到这一点?
这是我当前的代码:
def create
@business = Business.new(params[:business])
if @business.save
redirect_to :back, :notice => "You have successfully added a new business."
else
render :action => 'new', :notice => "Please try again."
end
end