Ruby on Rails Wednesday, July 12, 2017

What's the convention here: top posting or bottom posting?

Ralph


On Wednesday, July 12, 2017 at 7:52:06 AM UTC-6, Hassan Schroeder wrote:
On Wed, Jul 12, 2017 at 6:33 AM, Ralph Shnelvar <ral...@dos32.com> 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

  ActiveRecord::Base.establish_connection()

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

Aside:

> 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 :-)

HTH!
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a2db5d66-4ff1-4eb1-ba42-8ebf11954004%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment