I have to redirect from my server to the different server page by simulating the POST method submit from the Controller file, I tried using post_via_redire ct, but could not succeed... though redirect_to just redirects to given URL, I need to pass parameters using POST.
Configurations:
Rails 1.2.3,
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
Linux 2.6.9-42 box.
I used the following code in the action method:
post_via_redire ct("http://some_site:8080/login.xhtml",{: userName => 'login_id', :password => 'some_password' })
which failed to redirect and asking for the file template with the action name.
if I use redirect_to ("http://some_site:8080/login.xhtml") it will take me to login page, which I dont want, I should directly login without entering username and password.
If I call this page using HTML form Submit (POST method with username and password) it directly logs into the system.
Ex:
Expand|Select|Wrap|Line Numbers
- <form method=post action="http://some_site:8080/login.xhtml">
- <input type="hidden" id="userName" name="userName" value="login_id" >
- <br>
- <input type="hidden" id="password" name="password" value="some_password" >
- <br>
- <input type="submit" value="submit">
I have to click on the button in my home page, which calls a Controler/action
in that action, I need to redirect to new url (ex: http://new_site:8080/login)
while redirecting, I need to post the username and password as a POST arguments and NOT in the URL (get method).
If there are any Sample code, it will be very helpful.
Thanks,
Chandu