Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails AbstractController::Admin中的DoubleRenderError_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails AbstractController::Admin中的DoubleRenderError

Ruby on rails AbstractController::Admin中的DoubleRenderError,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,我正在从事spree commerce的工作,我正在尝试调整active_sale_控制器中的两个操作。我有一些条件,如果条件失败,我将把_重定向到(:back),否则我将继续下一步。我现在面临的问题是,我在同一个操作中使用了两次重定向到(:back),并且在同一个操作中还有一个重定向到其他控制器,浏览器显示了一个错误,显示为 "Render and/or redirect were called multiple times in this action. Please note that y

我正在从事spree commerce的工作,我正在尝试调整active_sale_控制器中的两个操作。我有一些条件,如果条件失败,我将把_重定向到(:back),否则我将继续下一步。我现在面临的问题是,我在同一个操作中使用了两次重定向到(:back),并且在同一个操作中还有一个重定向到其他控制器,浏览器显示了一个错误,显示为

"Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return"." 
这是我的密码

when "2"
    st_days = DateTime.strptime("#{start_date}","%d/%m/%Y %H:%M:%S")
    ed_days = DateTime.strptime("#{end_date}","%d/%m/%Y %H:%M:%S")
    ps = PoSale.where(:active_sale_id => @active_sale.id, :event_name => @taxon_name,:st_date => @start_date, :ed_date => @end_date).last
    if ((st_days >= ps.st_date and st_days <= ps.ed_date) or ( ed_days >= ps.st_date and ed_days <= ps.ed_date))   
        redirect_to (:back), :notice => "problem with the start_date and end_date"
    else
        PoSale.create(:active_sale_id => params[:id], :event_name => params[:active_sale]["taxon_name"], :st_date => DateTime.strptime("#{start_date}","%d/%m/%Y %H:%M:%S"), :ed_date => DateTime.strptime("#{end_date}","%d/%m/%Y %H:%M:%S"))
    end         
    when "3"
        puts "Inside 3"
        puts "*"*20
        #hidesd = DateTime.parse(params[:hide_start_date].split("+")[0])
        #hideed = DateTime.parse(params[:hide_end_date].split("+")[0])
        # hideed = DateTime.strptime("#{hide_end_date}","%d/%m/%Y %H:%M:%S")
        puts "*"*20
        #puts "Parameters:#{hidesd}"
        #puts hideed
        a_sale_id=params[:id].to_i
        #PoSale.where("active_sale_id = 310 and st_date = '2012-07-05 03:03:00' and ed_date ='2012-07-12 08:03:00'")
        st_days = DateTime.strptime("#{start_date}","%d/%m/%Y %H:%M:%S")
        ed_days = DateTime.strptime("#{end_date}","%d/%m/%Y %H:%M:%S")

        diff = (st_days.to_date - ed_days.to_date).to_i
        if diff > 10 
            redirect_to (:back), :notice => "more then 10 days not hapenning"      
        else
            ps = PoSale.where(:active_sale_id => a_sale_id, :event_name => @taxon_name, :st_date => @start_date, :ed_date => @end_date).last #where("active_sale_id =#{a_sale_id} and st_date like ? and ed_date like ?",hidesd.strftime("%Y-%m-%d %H:%M:%S"),hideed.strftime("%Y-%m-%d %H:%M:%S")).last #use find
            ps.update_attributes(:event_name => params[:active_sale]["taxon_name"], :st_date => DateTime.strptime("#{start_date}","%d/%m/%Y %H:%M:%S"), :ed_date => DateTime.strptime("#{end_date}","%d/%m/%Y %H:%M:%S"))
        end
当“2”时
st#u days=DateTime.strtime(“{start_date},“%d/%m/%Y%H:%m:%S”)
ed#u days=DateTime.strtime(“#{end_date},“%d/%m/%Y%H:%m:%S”)
ps=PoSale.where(:active\u sale\u id=>@active\u sale.id,:event\u name=>@taxon\u name,:st\u date=>@start\u date,:ed\u date=>@end\u date)。最后
如果((开始日期>=ps.st\U日期和结束日期=ps.st\U日期和结束日期)“开始日期和结束日期有问题”
其他的
创建(:active_sale_id=>params[:id],:event_name=>params[:active_sale][“taxon_name”],:st_date=>DateTime.strtime(“{start_date},“%d/%m/%Y%H:%m:%S”),:ed_date=>DateTime.strtime(“{end#date date},“%d/%m/%Y%H:%m:%S”))
终止
当“3”
把“3”放进去
放置“*”*20
#hidesd=DateTime.parse(参数[:hide\u start\u date]。拆分(“+”[0])
#hideed=DateTime.parse(参数[:hide\u end\u date]。拆分(“+”[0])
#hideed=DateTime.strtime(“{hide_end_date},“%d/%m/%Y%H:%m:%S”)
放置“*”*20
#放置“参数:#{hidesd}”
#藏身
a_sale_id=params[:id]。发送至_i
#PoSale.where(“有效销售id=310,销售日期='2012-07-05 03:03:00',销售日期='2012-07-12 08:03:00'”)
st#u days=DateTime.strtime(“{start_date},“%d/%m/%Y%H:%m:%S”)
ed#u days=DateTime.strtime(“#{end_date},“%d/%m/%Y%H:%m:%S”)
差异=(st_days.to_date-ed_days.to_date)。to_i
如果差异>10
将_重定向到(:返回),:notice=>“超过10天未出现”
其他的
ps=PoSale.where(:active_sale_id=>a_sale_id,:event_name=>@taxon_name,:st_date=>@start_date,:ed_date=>@end_date)。last#where(:active_sale_id={a_sale_id}和st_date like?和ed_date like?),hidesd.strftime(%Y-%m-%d%H:%m:%S),hideed.strftime.strftime(%Y-%m:%d:%S)。最后使用
ps.update_attributes(:event_name=>params[:active_sale][“taxon_name”],:st_date=>DateTime.strtime(“{start_date},“%d/%m/%Y%H:%m:%S”),:ed_date=>DateTime.strtime({end_date},“%d/%m/%H:%m:%S”))
终止

请帮帮我!!!

重定向到
不会停止操作方法的执行,因此如果您调用它并随后调用
渲染
或另一个
重定向到
您将得到双重渲染异常。有一个相当简单的修复方法,只需调用
并返回

redirect_to (:back), :notice => "problem with the start_date and end_date" and return

请参阅中的“避免双重渲染异常”。

重定向到
不会停止操作方法的执行,因此,如果您调用它并稍后调用
渲染
或另一个
重定向到
,您将获得双重渲染异常。有一个相当简单的修复方法,只需调用
并返回

redirect_to (:back), :notice => "problem with the start_date and end_date" and return
请参见中的“避免双重渲染异常”