HTTP POST and redirect_to a single rails view
I want to redirect_to a different Rails page, as well as pass some parameters which can be accessed in 开发者_如何学编程the other controller action. If I do it like this, it's a GET call by default(as per the HTTP specification), which means that the parameters will be visible in the URL (which is not a good idea.)
Controller1
Action1
redirect_to path_to_action2(:parameters => "values")
end
Controller2
Action2
#...parameters to be accessed here
end
A way of doing this can be introducing an intermediate step, by creating a POST form which displays a Dummy message to the user and makes the POST call for us. But I don't want to introduce an extra step, then how to do so?
Because of the way HTTP works, there is no way to do what you're asking. Every redirect is a GET. So why don't you like the parameters to be visible? How important is this?
Flash messages do something similar. They store the message in the users session and destroy it in the next request. You could use that. I would try to avoid this kind of message passing first though.
精彩评论