RateMyArea - interesting rails bits
-
Upload
ciaran-lee -
Category
Technology
-
view
730 -
download
1
description
Transcript of RateMyArea - interesting rails bits
Ciarán Lee
RateMyArea.com
• Local-Social-Search• Starting off in Dublin• Launched 7 November• Rails app
Interesting things we have done
• Search
• Caching
• iPhone web app
Search
Search = sphinx
• moving from ultrasphinx to thinking_sphinx
• more actively developed
• nice syntax
• we are overhauling search
geo-search• sphinx does this very well• insists on radians• ultrasphinx provides a nice interface
# CREATE AN INDEXdefine_index do indexes :name has "RADIANS(latitude)", :as => :latitude, :type => :float has "RADIANS(longitude)", :as => :longitude, :type => :floatend
# RUN A SEARCH for popular bars nearby@bars = Listing.search("bar", :per_page => 10, :page => 1, :geo => [deg2rad(@where.latitude), deg2rad(@where.longitude)], :order => average_rating DESC, :with => {"@geodist" => 0.0..2000})
caching - in order of preference
1. Page caching
2. Action caching
3. Fragment caching
Caching
Page caching not possible if content changes for ANY user *
Action caching can be used conditionally - for logged out users
* unless server side includes (SSI) are used
caches_action :show ,:if => Proc.new { |controller| controller.send(:logged_out?) }
20,000 action cached places
But... the footer is dynamic
How to keep the action cache but change the footer?
Server Side IncludesWikipedia:
“As its name implies, its primary use is including the contents of one file into another one dynamically when the latter is served by a web server.”
<!--# include virtual="/ssi/footer" -->
The webserver inserts the contents of the include before sending the response to the client
http://blog.kovyrin.net/2007/08/05/using-nginx-ssi-and-memcache-to-make-your-web-applications-faster/
http://www.jkraemer.net/tags/nginx
also...
• Object caching can be handy for expensive queries• these objects can be fetched out of request/
response cycle (we use workling for this)
• don’t keep page cache in RAILS_ROOT/public - this will preserve it through redeployshttp://blog.hasmanythrough.com/2008/1/30/segregated-page-cache-storage
RateMyArea on your mobile(if you have an iPhone)
• We like MobileSafari!
• iUi used for the interface• development has stalled• good starting point... • Flickr agree with copied us :)
http://code.flickr.com/blog/2008/10/27/lessons-learned-while-building-an-iphone-site/
RateMyArea on your mobile(if you have an iPhone)
• No access to CoreLocation through the browser :(• phonegap can fix this• native iPhone app• wraps a web-app• really is a site specific browser• http://github.com/sintaxi/phonegap/tree/master
Maps on the iPhone
• Native app is really nice• can render kml• different firmware versions have different
capabilities :(
Thank [email protected]