Calling remote url application from controller

I have two rails application.
On clicking a link on Application 1’s index.html.rb page I wish to do
some processing like retreiving info about the selected record from DB.
and then make a call to a different rails application.
Do I need to write code in my view using helper functions or I can do
this in controller.
I wish to do this in controller… as it will mean a cleaner code in
view.
Is there some dispatch mechanism available in Rails controller.

What exactly does “make a call to a different rails application” mean?

Sharagoz – wrote:

What exactly does “make a call to a different rails application” mean?

For example
I wish to call www.google.com with some parameters from my rails
application then what should I do.
I am firing some soap requests to get those input parameters for google.
Hence I need to write some code in my controller.
Something like I am calling show function of scaffold generated project
and there I am calling google.com iso default show.html created by
scaffold

Then you can use ‘net/http’ to send a regular http request, like so:

require ‘net/http’

connection = Net::HTTP.new(“www.google.com”)
response = “”
connection.start do |http|
req =
Net::HTTP::Get.new("/#hl=en&source=hp&q=ruby+on+rails&fp=c26c79a56c95bda8")
response = http.request(req)
end
#do something with response

This can of course be put in the controller, but also the model if that
suits you better.

Sharagoz – wrote:

Then you can use ‘net/http’ to send a regular http request, like so:

require ‘net/http’

connection = Net::HTTP.new(“www.google.com”)
response = “”
connection.start do |http|
req =
Net::HTTP::Get.new("/#hl=en&source=hp&q=ruby+on+rails&fp=c26c79a56c95bda8")
response = http.request(req)
end
#do something with response

This can of course be put in the controller, but also the model if that
suits you better.

How can I open the page in a new browser.

I see. Can’t you just put :popup => true on the link in the view, and
then use a redirect_to in the controller?

Sharagoz – wrote:

I see. Can’t you just put :popup => true on the link in the view, and
then use a redirect_to in the controller?

Thanks. The solution works as it opens the required page.

Prashant Thakur wrote:

Sharagoz – wrote:

Then you can use ‘net/http’ to send a regular http request, like so:

require ‘net/http’

connection = Net::HTTP.new(“www.google.com”)
response = “”
connection.start do |http|
req =
Net::HTTP::Get.new("/#hl=en&source=hp&q=ruby+on+rails&fp=c26c79a56c95bda8")
response = http.request(req)
end
#do something with response

This can of course be put in the controller, but also the model if that
suits you better.

How can I open the page in a new browser.

Basically I wish to open the 2nd page by specifying its url and
parameters in a different window by clicking a link in first application
this link will call the controller function where soap requests will be
sent to server and based on that reponse I open a new website with
parameters.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs