[rspec-users] redirect_to(:action => 'foo') and return
dchelimsky at gmail.com
Sat Dec 30 23:13:04 EST 2006
On 12/30/06, Courtenay <court3nay at gmail.com> wrote:
> I'm not sure why this is happening, but if I do this in a controller
> unless @variation && @variation.quantity > 0
> flash[:error] = "Sorry, that product is currently not available."
> redirect_to(:action => 'error') and return
> rspec tells me
> ActionController::DoubleRenderError in 'The Carts controller with an
> existing User should add items to the cart'
> Render and/or redirect were called multiple times in this action.
> Please note that you may only call render OR redirect, and only 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". Finally, note that to cause a before filter to halt execution
> of the rest of the filter chain, the filter must return false,
> explicitly, so "render(...) and return false".
> however if I change that to
> redirect_to(:action => 'error')
> it works just fine. All versions of "..and return" seem to fail.
Please raise a bug on this.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users