我的控制器文件如下所示:
class QuotesController < ApplicationController
def show
@quote = Quote.find(params[:id])
@popup = params[:popup]
respond_to do |format|
if @popup.present?
format.html { render layout: false }
else
format.html
end
format.json { render json: @quote }
end
end
def create
@quote = Quote.new(params[:quote])
respond_to do |format|
if @quote.save
format.html { redirect_to @quote, notice: "Quote was successfully created.", popup: "1" }
format.json { render json: @quote, status: :created, location: @quote }
else
format.html { render action: "errors", layout: false }
format.json { render json: @quote.errors, status: :unprocessable_entity }
end
end
end
end
如果我访问http://localhost:3000/quotes/1?popup=1 - 视图正确显示而没有 application_layout
但是,如果我来自 CREATE 操作,似乎 ?popup=1 永远不会附加到 URL - 因此 application_layout 在不应该显示的时候显示
我认为将 popup: "1" 添加到 redirect_to 行应该通过 GET 传递一个参数
谁能看到我错过了什么?
谢谢