I’m sure this is a bone-headed question, so apologies in advance. I want to use a string with my redirect_to, like this:
class AppStoreController < ApplicationController
def get_app
.
.
.
redirect_path_string = "address_book_path"
redirect_to redirect_path_string
end
end
(The redirect_path_string will be constructed using available variables in the controller, but I wanted to abstract out that detail for this question.)
When I do this, I get “The connection was reset” in my browser.
Any thoughts?
You need to supply a fully qualified URL in order to use a string against redirect_to. Rails utilize a convention to generate a URL from *_path, in this case ‘address_book_path’. The following is some examples of what you can do with redirect_to. For more info, go to http://apidock.com/rails/ActionController/Base/redirect_to