0
특정 작업은 uri
매개 변수에 따라 html 페이지를로드해야합니다. 현재 서버의 uri를 제외한 모든 유효한 uris에 대해 정상적으로 작동합니다. 컨트롤러 내에서 페이지를 요청하는 쉬운 방법이 있습니까?레일즈 페이지에서 레일스 페이지를 요청하려면 어떻게해야합니까?
require 'uri'
class MainController < ApplicationController
def foo
uri = URI(params[:uri])
if uri.host =~ /localhost|mydomain\.com/
# what goes here?
else
@html = Net::HTTP.get(uri)
end
# Do something useful with @html...
end
end
# The code should work for http://localhost/foo?uri=http://apple.com/
# as well as for http://localhost/foo?uri=http://localhost/bar
내가 말했듯이 로컬 URL에는 작동하지 않습니다. 내부 HTTP.get 시간이 초과되었습니다. –
1 mongrel 서버의 개발 모드 또는 한 번에 둘 이상의 연결을 처리 할 수있는 Passenger와 같은 프로덕션 모드에서? – jdl
또한 생산에서, Heroku에. 이유는 모르겠지만 2dynos에서는 작동하지 않지만 3dynos에서는 작동합니다. 그러면, 할 것이다 :-) –