RateMyArea - interesting rails bits

17
Ciarán Lee

description

The slides from a presentation I gave at the Ruby Ireland meetup on December 9

Transcript of RateMyArea - interesting rails bits

Page 1: RateMyArea - interesting rails bits

Ciarán Lee

Page 2: RateMyArea - interesting rails bits
Page 3: RateMyArea - interesting rails bits

RateMyArea.com

• Local-Social-Search• Starting off in Dublin• Launched 7 November• Rails app

Page 4: RateMyArea - interesting rails bits

Interesting things we have done

• Search

• Caching

• iPhone web app

Page 5: RateMyArea - interesting rails bits

Search

Page 6: RateMyArea - interesting rails bits

Search = sphinx

• moving from ultrasphinx to thinking_sphinx

• more actively developed

• nice syntax

• we are overhauling search

Page 7: RateMyArea - interesting rails bits

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})

Page 8: RateMyArea - interesting rails bits

caching - in order of preference

1. Page caching

2. Action caching

3. Fragment caching

Page 9: RateMyArea - interesting rails bits

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?) }

Page 10: RateMyArea - interesting rails bits

20,000 action cached places

But... the footer is dynamic

How to keep the action cache but change the footer?

Page 11: RateMyArea - interesting rails bits

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

Page 12: RateMyArea - interesting rails bits

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

Page 13: RateMyArea - interesting rails bits

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/

Page 14: RateMyArea - interesting rails bits

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

Page 15: RateMyArea - interesting rails bits

Maps on the iPhone

• Native app is really nice• can render kml• different firmware versions have different

capabilities :(

Page 16: RateMyArea - interesting rails bits
Page 17: RateMyArea - interesting rails bits

Thank [email protected]