geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

Check to see if adapter is loaded before requiring an explicit file #83

Closed rusterholz closed 9 years ago

rusterholz commented 9 years ago

This change simply checks to see if the database-specific adapter is already loaded before it tries to require a file with an explicit path. With this change, projects that use geokit-rails can choose to provide their own adapters in initializers without causing unnecessary UnsupportedAdapter errors.

This simple change is the end of a very long story for my team. (Read on if you dare!) Our Rails app uses a custom database adapter to perform cryptographic functions (the excellent pgcrypto adapter by @flipsasser). For Geokit's purposes, the PGCrypto adapter can be treated identically to the PostgreSQL adapter. We had a lot of trouble getting geokit-rails to handle the situation correctly:

After tearing our hair out for a while, we decided that the best solution was to fork the gem and submit the PR you see here. We think this is a pretty common-sense solution that might benefit others without requiring any other changes.

mnoack commented 9 years ago

Sorry for not merging this earlier. Excellent fix, although I hope it doesn't result in people not submitting their geocoders via PR's