user2712937
user2712937

Reputation: 291

Rails redirect without using redirect_to

Rails redirect_to method performs some validations on the URI (I believe uses URI.parse) and will throw errors if it contains invalid characters that are un-escaped or simply a malformed uri.

I would really like to implement my own redirect_to method which will simply redirect to any string I give it to, and render a status code of 302.

Does anyone know if this is possible? Appreciate any help or suggestions

Upvotes: 0

Views: 224

Answers (1)

qichunren
qichunren

Reputation: 4475

Just use head method in controller:

# action method def create head 302, :location => "http://www.google.com" end

Upvotes: 1

Related Questions