Reginaldo Junior
2014-May-19 02:18 UTC
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 ? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b4d49af5-1a68-430f-ad7b-11f1287516db%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.