0

I'm using pgcrypto gem to encrypt data in certain columns of the database, but in order for this gem to work I have to specify pgcrypto as an adapter in database.yml file. I know that Heroku disregards this file and generates its own when application is pushed to Heroku server, which uses default postgresql adapter. Does anybody know if it's possible to override adapter value, with a configuration variable for example?

koss
  • 874
  • 1
  • 10
  • 22

2 Answers2

1

Eventually found the solution, which happened to be a quite simple one - I just had to replace the first token in the Heroku's database URL variable, so instead of

postgres://username:password@host:port/dbname

I use

pgcrypto://username:password@host:port/dbname

koss
  • 874
  • 1
  • 10
  • 22
0

You can manually create a database connection with

`ActiveRecord::Base.establish_connection(config)

you could also do this on a per-model basis using a mixing.

More info is here Understanding how establish_connection works in ActiveRecord

Community
  • 1
  • 1
John Paul Ashenfelter
  • 3,135
  • 1
  • 22
  • 29
  • Thank you for reply. I thought about that but really didn't want to have to specify all the connection properties for every model since I was only concerned about one particular setting - adapter. – koss Dec 18 '14 at 05:46