does rails postgres adapter support ssl?

前端 未结 5 886
温柔的废话
温柔的废话 2020-12-19 01:31

i\'m trying to configure a rails app to remotely connect to a postgres db. i\'ve noticed that the connection adapters for mysql have options that specify the required info f

5条回答
  •  攒了一身酷
    2020-12-19 02:00

    I came to this after looking into the exact same question as the OP and wasn't quite satisfied with any of the answers because I am using the pg gem as well and it's the only one supported enough for Rails 2.X.

    After some investigation by my co-worker he realized the following:

    In Rails 4, you can just specify a variables hash to do this (http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html) but it doesn't exist in Rails 2 (http://api.rubyonrails.org/v2.3.8/classes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html)

    Because of this we can simply remove the typical config and toss everything into the database argument and call it a day (much like the original answer whitehat101 posted with the jdbc adapter)

    Below is the implementation that you would use to connect to a remote server and use the sslmode desired.

    development:
        adapter: postgresql
        database: "host=db-serv dbname=admin_production user=XX password=XX sslmode=verify-ca"
    

提交回复
热议问题