Ruby on Rails Wednesday, July 12, 2017

On Wed, Jul 12, 2017 at 6:33 AM, Ralph Shnelvar <> wrote:

> I _think_ I need to do something like "sudo -i -u SomeOtherPostgresUserName"
> but I want to do it inside Rails so I can connect to databases as user
> SomeOtherPostgresUserName.

I would look at


which accepts either an atom representing an entry in your
config/database.yml or a hash with DB login credentials.


> class RalphSql
> def self.exec_sql(sql_text)
> begin
> # Return an array of records
> return ActiveRecord::Base.connection.execute(sql_text)

I hope you really really REALLY trust the input from your users
and do very frequent backups :-)

Hassan Schroeder ------------------------
twitter: @hassan
Consulting Availability : Silicon Valley or remote

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment