Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: redirect_to(...) and return vs return redirect_to

When redirecting in rails 3,

Is return redirect_to(...) a valid Rails statement?

I've always just used redirect_to(...) and return but I saw a line like the one described above and I was surprised to see that it also worked.

like image 271
turntwo Avatar asked Dec 10 '25 04:12

turntwo


1 Answers

Is return redirect_to(...) a valid Rails statement?

Yes.

Statement validity is not determined by Rails, it is determined by Ruby. And in Ruby return something is perfectly valid.

like image 173
Andrey Deineko Avatar answered Dec 12 '25 23:12

Andrey Deineko