The docs suggest something along the lines of:
# connection setup
ActiveRecord::Base.establish_connection(
:adapter => 'jdbc',
:driver => 'org.postgresql.Driver',
:url => 'jdbc:postgresql:sample_db;create=true'
)
Or
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
database: 'db/my-database'
)
This is assuming you're using JDBC and the appropriate configuration. For this, I suggest taking a look at Postgres' documentation.
Sample provided over there is written in Java:
String url = "jdbc:postgresql://localhost/test";
Properties props = new Properties();
props.setProperty("user","fred");
props.setProperty("password","secret");
props.setProperty("ssl","true");
Connection conn = DriverManager.getConnection(url, props);
String url = "jdbc:postgresql://localhost/test?user=fred&password=secret&ssl=true";
Connection conn = DriverManager.getConnection(url);
...but I'd roll with something along those lines:
ActiveRecord::Base.establish_connection(
:adapter => 'jdbc',
:driver => 'org.postgresql.Driver',
:url => 'jdbc:postgresql:sample_db;create=true'
:user => 'myuser'
:password => 's3cret!'
)
Alternatively, there's JRuby-PG
Regards,