Noah February 2016

Rails AbstractController::DoubleRenderError despite returning a redirect_to

My Rails app is throwing a AbstractController::DoubleRenderError. You can see my controller action below, it does include multiple render and/or redirects, however, I've read and found that doing it with a return should negate this exception.

Here is my controller action:

def load
  redirect_to login and return if @current_login == nil

  render template: 'app' and return if @current_login
end

I've verified that @current_login is nil, meaning it should redirect and return.

Answers


Noah February 2016

Changing redirect_to login to redirect_to '/login' did the trick.

I had a controller action login in the same controller as the load action, so it was calling the login action, which had a render call in it...

Hopefully someone runs into the same coincidence and this helps them.

Post Status

Asked in February 2016
Viewed 3,395 times
Voted 5
Answered 1 times

Search




Leave an answer