How to abstract away a Location model with Geocoder.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib
public
test
vendor/assets
.gitignore
Gemfile
Gemfile.lock
README.md
README.rdoc
Rakefile
config.ru

README.md

Geocoder-Polymorphism-Example

The code from my blog post: http://www.breefield.com/essays/polymorphic-geocoder

To play with polymorphic joins on a geocoded Location model do the following Clone the repo, it runs on Sqlite, so no need to setup a DB. Run rake db:migrate then rake db:seed Now run rails console and then try this out:

Location.near('San Francisco', 50).filter_by(:event).where('events.price <= ?', 20)

Know that Location has a polymorphic relationship with both ````EventandVenue```.

class Location < ActiveRecord::Base
  belongs_to :located, :polymorphic => true
end