I am using Play Framework 2.0 with Scala.
So I have an action that is for a post request. I want to do some validation on the input data, and if the input is not valid, redirect to some other controller action (for example back to the prev page and tell the user the input was invalid)
My code looks something like this:
if ( input.isNotValid )
Redirect( foo )
// ... more code
Redirect( bar )
So the validation is early on, there are lines of code after that, and at the very end of the action I redirect to a different page.
My problem is that even when the validation fails, the page is not redirecting to Foo. The code works if I do this instead:
if ( input.isNotValid )
Redirect( foo )
else
Redirect( bar )
Am I required to put all my Redirects and Oks at the end of the action?
I know in Ruby on Rails sometimes this happens, and a solution to that is to put "and return" after every redirect. Is there something I have to do in Play Framework too?