takafumir / rails_amp

RailsAmp is a Ruby on Rails plugin for AMP(Accelerated Mobile Pages).
MIT License
65 stars 26 forks source link

Avoid to render or redirect multiple times #2

Closed fbbergamo closed 7 years ago

fbbergamo commented 7 years ago

This PR fix this error:

AbstractController::DoubleRenderError (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 tried to request a AMP page but the app redirects or render before is raising that error.

I think that the best approach is to check if render or redirect has already been called before.

takafumir commented 7 years ago

Thank you for the pull request! Just merged it. I appreciate that you found this bug, and I confirmed the solution works well. 👍