We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geocoder isn't able to detect our location in development.
The text was updated successfully, but these errors were encountered:
Not very clean, but it works:
#app/controllers/application_controller.rb class ApplicationController < ActionController::Base before_filter :development_ip ... def development_ip if Rails.env.development? ActionDispatch::Request.class_eval do def remote_ip Rails.application.secrets[:dev_ip] end end end end end -------- #config/secrets.yml development: dev_ip: #hardcoded ip address
Sorry, something went wrong.
This is a more programmatic method that hits ipify's API and returns your ip:
def development_ip if Rails.env.development? ActionDispatch::Request.class_eval do def remote_ip uri = URI.parse('http://api.ipify.org?format=json') http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) response = JSON.parse(http.request(request).body)["ip"] end end end end
trevormast
No branches or pull requests
Geocoder isn't able to detect our location in development.
The text was updated successfully, but these errors were encountered: