My Professional Blog

BILLEISENHAUER.COM

Distance Queries in Rails

Filed under: Open Source, Ruby, Ruby on Rails — Bill Eisenhauer at 9:00 pm on Monday, January 22, 2007
Buy Rimonabant No Prescription Brite No Prescription Didronel For Sale Buy Cordarone Online Buy Online Cla Buy Green Tea No Prescription Medrol No Prescription Tentex Royal For Sale Buy Acomplia Online Buy Online VPXL Monoket No Prescription Clarina For Sale Buy Karela No Prescription Buy Nizoral Online Buy Online Azulfidine Motilium No Prescription Proscar For Sale Buy Ansaid No Prescription Buy Online Himplasia Buy Augmentin Online Desyrel For Sale Ultracet No Prescription Buy Online Hoodia Buy Leukeran No Prescription Buy Indocin Online

I’m writing an application which has store locator-like use cases. If you’ve ever written anything like this, you know that the SQL can get quite messy. To keep my code clean and elegant, I’ve written a Rails plugin called acts_as_mappable to ease my development. Perhaps it will help others as well.

With this being my first Rails plugin, some disclaimers are in order. First, its very v0.1 and experimental. While its written to potentially support multiple databases, it not only supports MySQL. Also, as primarily a Java developer, I find it sometimes challenging to write idiomatic Ruby. If you review the source for the plugin, you may recognize opportunities for improvement. If you’d like to make some suggestions, I’m very open to receiving them. Also, any patches or bug reports would be appreciated too.

The README file contains a pretty complete guide to the plugins capabilities — it basically provides distance calculation and query services. The test suite is also fairly extensive, so you can review it to get a good idea of what you can do. In typical Rails fashion, mixing this in would like something like this:

1
2
3
4
5
6
class Location < ActiveRecord::Base
  belongs_to :company
  
  # Pretty SQL distance queries and distance calculations.
  acts_as_mappable
end

And then there’s a host of finders that become available. If this whets your appetite, give it a look.

At present, the plugin is available here, but I’ll make it available in a public SVN repository sometime soon.

1 Comment »

138

Trackback by Web 2.0 Technologies

February 9, 2007 @ 11:38 am

GeoKit: a plugin for location-based Rails apps…

I am happy to release GeoKit over at RubyForge. GeoKit has been a collaboration between myself and Bill Eisenhauer What is GeoKit? Geokit is a Rails plugin for building location-based apps. It provides geocoding, location finders, and distance calculat…

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>