Wenn jemand meine Rails-Anwendung in China öffnen, möchte ich meine URL ändern www.example.com www.example.cn. Wie ist es möglich? Ich habe diese Aufgabe erledigt von Javascript Wurzelindexseite hinzugefügt, aber ich denke, das ist eine nicht eine gute Idee, das heißt
<script type=text/javascript>
<% country_code = find_geo %>
<% if country_code.downcase == ch %>
window.location.href = 'http://example.cn/';
<% end %>
</script>
und in application_helper.erb ein Verfahren hinzuzufügen,
def find_geo
country_code = request.location.country_code
end
Ich bin mit Geocoder für request.location.country_code.













