How to display external site in rails view?
2 answers
This is a universal approach:
class YahooController < ApplicationController
layout false
def show
url = URI.parse('http://www.yahoo.com/')
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
@body = res.body
end
end
In view
# views/yahoo/show.html.haml
= @body.html_safe
You will need a route to this, of course.
# routes.rb
get '/yahoo', :to => 'yahoo#show'
+2
source to share