问题
My app has the following controller action:
def test
#get URL
url = "http://www.coteur.com/surebet.php"
doc = Nokogiri::HTML(open(url))
@show = doc.at_css("title").text
@game_data = Array.new
doc.css('tbody').each do |tr|
tr.css("tr").each do |f|
@game_data.push(f.css("td").text)
end
end
end
And render the following view:
<%= @show%>
<div class="bs-example" data-example-id="hoverable-table">
<table class="table table-hover">
<tbody>
<% if @game_data.empty? %>
<tr>
<td>Nope</td>
</tr>
<%else%>
<% @game_data.each do |game|%>
<tr>
<td><%= game%></td>
</tr>
<%end%>
<%end%>
</tbody>
</table>
</div>
Everything work fine locally but on Heroku the <%= @game_data%>
appears to be empty while it should not be. The problem is that in the US it does not work but in the EU it does. So how can I work this around with a proxy or changing the server location or something else ?
回答1:
You can fork your current Heroku app into the European region with:
$ heroku fork --region eu
Creating fork myapp-332... done
Copying slug... done
Copying config vars... done
Fork complete, view it at http://myapp-332.herokuapp.com/
Now you'll have a copy of your app running in Europe, which may work better for you. If that works you can keep the new app and shut down the old one.
See the fork application docs for more details.
来源:https://stackoverflow.com/questions/29680726/how-can-i-parse-a-url-using-a-proxy-with-rails