redirect_to != return

Yes, you need to return from method when doing redirect. It actually only adds appropriate headers for the response object.

You can write more rubyish way:

if some_condition
    return redirect_to(path_one)
end

redirect_to(path_two)

or other way:

return redirect_to(some_condition ? path_one : path_two)

or another way:

redirect_path = path_one

if some_condition
    redirect_path = path_two
end

redirect_to redirect_path

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)