ruby - No such file or directory - GeoCity.dat Rails -
i'm trying setup rails server u.s. users able take survey on site. installed geoip gem , downloaded country file maxmind.com.
i'm able create new geoip object ip address in rails console. when actual request in controller gives error:
no such file or directory - geocity.dat
here's controller:
module api module v1 class surveyscontroller < applicationcontroller before_filter :check_us def survey @survey = survey.check_survey params[:user_auth_token] redirect_to api_v1_survey_path(@survey) end private def check_us c = geoip.new('geocity.dat').country(request.remote_ip) head :unauthorized unless c.country_code2 = "us" end end end end
i have geoip.dat file unzipped , sitting in main rails directory. i'm thinking need load database or of like? in advance!
assuming geocity.dat
in main rails root directory. use below:
c = geoip.new("#{rails.root}/geocity.dat").country(request.remote_ip)
Comments
Post a Comment