From: Benjamin Mako Hill Date: Sun, 17 Jun 2012 22:42:57 +0000 (-0400) Subject: fixed and re-enabled support for memcache in the production site X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/2facf9c3cba1ddc270c84a713cafbe6eb7280efd fixed and re-enabled support for memcache in the production site --- diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index c32d585..b57abaa 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -161,7 +161,7 @@ class QuickvoteController < ApplicationController else # record the ip address for posterity - @voter.ipaddress = request.env["REMOTE_ADDR"] + @voter.ipaddress = request.env["HTTP_X_FORWARDED_FOR"] @voter.save # toggle the confirmation bit @@ -186,9 +186,10 @@ class QuickvoteController < ApplicationController @election=QuickVote.ident_to_quickvote(params[:id]) @election.voters.each do |voter| next unless voter.ipaddress + location=nil - if defined? Cache and location=Cache.get("GEO:#{voter.ipaddress}") - elsif defined? Cache + if Cache and location=Cache.get("GEO:#{voter.ipaddress}") + elsif Cache location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress) Cache.set "GEO:#{voter.ipaddress}", location else diff --git a/config/environments/development.rb b/config/environments/development.rb index 2d7f978..669f755 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,6 +1,7 @@ # Settings specified here will take precedence over those in config/environment.rb #disable memcache Cache=nil + # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. diff --git a/config/environments/production.rb b/config/environments/production.rb index 20ded00..4bb1351 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,9 +1,9 @@ # Settings specified here will take precedence over those in config/environment.rb # #Enable memcache -#require('memcache') -#Cache=MemCache.new('localhost', :compression => true) -Cache=nil +require('memcache') +Cache=MemCache.new('localhost', :compression => true) + # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true diff --git a/config/environments/test.rb b/config/environments/test.rb index a1a2608..f1ab738 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,6 +1,7 @@ # Settings specified here will take precedence over those in config/environment.rb #disable memcache Cache=nil + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped