Note that there are some explanatory texts on larger screens.

plurals
  1. POAbstractController::DoubleRenderError in Admin
    primarykey
    data
    text
    <p>I am working on spree commerce, I am trying to tweak couple of actions in the active_sale_controller. I have some conditions, if the condition fails I am redirecting_to (:back) else I am proceeding to next step. The problem I am facing right now is I have used redirected_to (:back), twice in the same action and also I have one more redirected_to to some other controller in the same action, the browser shows a error which is says </p> <pre><code>"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"." </code></pre> <p>here is my code </p> <pre><code>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 =&gt; @active_sale.id, :event_name =&gt; @taxon_name,:st_date =&gt; @start_date, :ed_date =&gt; @end_date).last if ((st_days &gt;= ps.st_date and st_days &lt;= ps.ed_date) or ( ed_days &gt;= ps.st_date and ed_days &lt;= ps.ed_date)) redirect_to (:back), :notice =&gt; "problem with the start_date and end_date" else PoSale.create(:active_sale_id =&gt; params[:id], :event_name =&gt; params[:active_sale]["taxon_name"], :st_date =&gt; DateTime.strptime("#{start_date}","%d/%m/%Y %H:%M:%S"), :ed_date =&gt; 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 &gt; 10 redirect_to (:back), :notice =&gt; "more then 10 days not hapenning" else ps = PoSale.where(:active_sale_id =&gt; a_sale_id, :event_name =&gt; @taxon_name, :st_date =&gt; @start_date, :ed_date =&gt; @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 =&gt; params[:active_sale]["taxon_name"], :st_date =&gt; DateTime.strptime("#{start_date}","%d/%m/%Y %H:%M:%S"), :ed_date =&gt; DateTime.strptime("#{end_date}","%d/%m/%Y %H:%M:%S")) end </code></pre> <p>Kindly help me out !!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload