Last active
December 26, 2015 22:09
-
-
Save workmaster2n/7221549 to your computer and use it in GitHub Desktop.
Use postgis with nitrous.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export DATABASE_URL=username:password@host:port/dbname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Daniel Azuma wrote the necessary gems and has a blog series on postgis/rails. Follow his instructions for the "normal" setup: http://blog.daniel-azuma.com/archives/69 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #From: https://devcenter.heroku.com/articles/postgis?preview=1#setting-up-postgis-with-rails | |
| #possible bugs: http://stackoverflow.com/questions/16547916/undefined-method-when-trying-to-build-db-with-activerecord-postgis-adapter | |
| # in config/application.rb, before the application loads | |
| class ActiveRecordOverrideRailtie < Rails::Railtie | |
| initializer "active_record.initialize_database.override" do |app| | |
| ActiveSupport.on_load(:active_record) do | |
| if url = ENV['DATABASE_URL'] | |
| ActiveRecord::Base.connection_pool.disconnect! | |
| parsed_url = URI.parse(url) | |
| config = { | |
| adapter: 'postgis', | |
| host: parsed_url.host, | |
| encoding: 'unicode', | |
| database: parsed_url.path.split("/")[-1], | |
| port: parsed_url.port, | |
| username: parsed_url.user, | |
| password: parsed_url.password | |
| } | |
| establish_connection(config) | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From: https://github.com/dazuma/rgeo | |
| gem install rgeo -- --with-geos-dir=/path/to/my/geos/installation | |
| #note the -- to separate the build commands from the gem commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment