My controller file looks like this:
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
If I visit http://localhost:3000/quotes/1?popup=1 — the view correctly displays without application_layout
However, if I am coming from the CREATE action, it seems ?popup=1 is never being appended to the URL – and therefore the application_layout is displaying when it should not be
I thought that adding popup: “1” to the redirect_to line was supposed to pass a param via GET
Can anyone see what I am missing?
Thanks
Edit: tried this on my machine and it worked:
{ redirect_to quote_path(@quote, :popup => "1"), notice: "Quote was successfully created." }