2012-04-08 61 views
2

我的控制文件参数通道看起来是这样的:Ruby on Rails的redirect_to的工作不

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

视图显示正确但是,如果我从新建到来行动,它似乎?popup = 1永远不会被追加到URL - 因此,application_layout显示时,它不应该是

我认为向redirect_to行添加弹出:“1”应该传递一个参数通过GET

任何人都可以看到我失踪了吗?

感谢

回答

0

编辑:想这在我的机器上,并且它的工作:

{ redirect_to quote_path(@quote, :popup => "1"), notice: "Quote was successfully created." }

+0

没有错误,但仍然没有通过参数,我使用Rails 3.2如果有帮助 – samJL 2012-04-08 22:35:49

+0

@samJL编辑我的答案! – TheDude 2012-04-09 03:26:51

+0

@samJL让我知道如果我更新的答案工作! – TheDude 2012-04-09 17:03:24

0

尝试@quote_url(:popup=>1)我想它会工作。

+0

生成语法错误,我也试过@quote_path。 – samJL 2012-04-08 22:38:05

相关问题