Can ActiveRecord::Base.connection.schema_search_path be set per process?

I am building an app that every company has it own private
schema(Postgresql).

For every requisition, I set the Postgres search path in a before_action
like this:

ActiveRecord::Base.connection.schema_search_path = ‘company_id, public’

If I have multiple Unicorn workers, and one worker ‘A’ set the path,
while
another work ‘B’ set the path before worker A has finish, I think it
will
generate some conflict and ‘A’ worker could accidently save/read models
from the wrong schema, right?

Is this solution going to fail even if Unicorn is one thread per
worker(process)? If this is not the right way, what else can I do? Is it
possible for ActiveRecord to set namespaces for tables( Specify schemas
in
query) like:

Select * from ‘company_1’.clients

?

On Monday, May 19, 2014 2:18:30 PM UTC+12, Reginaldo Junior wrote:

I am building an app that every company has it own private schema(Postgresql).
For every requisition, I set the Postgres search path in a before_action like
this:ActiveRecord::Base.connection.schema_search_path = ‘company_id, public’

If I have multiple Unicorn workers, and one worker ‘A’ set the path, while
another work ‘B’ set the path before worker A has finish, I think it will generate
some conflict and ‘A’ worker could accidently save/read models from the wrong
schema, right?

What you do in one process won’t affect the other

Fred

I mean, is there a better solution that fits better Unicorn design?
Em segunda-feira, 19 de maio de 2014 03h48min14s UTC-3, Frederick C.
escreveu:

One more thing guys, could someone please tell me if the ORM will need
to
re-load its schema( table metadata) on each request if I set the
Postgres
search path?

Em domingo, 18 de maio de 2014 23h18min30s UTC-3, Reginaldo Junior
escreveu:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs