redirect to_back

I am seeing some more differences between 1.2.x and 2.3.2 and they just baffle me.

def some_method   if params[:report][:salesmancode].to_s == '' || !     params[:report][:periodno]     flash[:message] = "You forgot to select an employee or pick a time     period"     redirect_to :back   else     blah, blah   end   render :layout => false end

and I get a message about not being able to render/direct to more than 1 time. Why doesn't 'redirect_to :back' simply end processing and redirect the user? Is there some better way of doing this now?

Craig

I am seeing some more differences between 1.2.x and 2.3.2 and they just baffle me.

def some_method if params[:report][:salesmancode].to_s == '' || ! params[:report][:periodno] flash[:message] = "You forgot to select an employee or pick a time period" redirect_to :back

return false

> > I am seeing some more differences between 1.2.x and 2.3.2 and they just > baffle me. > > def some_method > if params[:report][:salesmancode].to_s == '' || ! > params[:report][:periodno] > flash[:message] = "You forgot to select an employee or pick a time > period" > redirect_to :back

return false

Hi Craig,

I am seeing some more differences between 1.2.x and 2.3.2 and they just baffle me.

def some_method   if params[:report][:salesmancode].to_s == '' || !     params[:report][:periodno]     flash[:message] = "You forgot to select an employee or pick a time     period"     redirect_to :back   else     blah, blah

      render :layout => false

  end end

and I get a message about not being able to render/direct to more than 1 time. Why doesn't 'redirect_to :back' simply end processing and redirect the user? Is there some better way of doing this now?

It is a little confusing but the short answer is don't count on render and redirect statements executing immediately. The best fix here is to put your render :layout => false inside your else clause. That way there's no possibility of rendering twice.

HTH, Bill