Hello,
I am trying to convert three applications to multitenant, all of them
have
same structure difference is only in little functions and template
designs.
All of them using cattr_accessor for setting currencies and other data,
and
it works perfectly
Now i added app_id as cattr_accessor to App model to use it in
default_scope to implement multi-tenancy
class App < ActiveRecord::Base
attr_accessible :active, :name
cattr_accessor :app_id, :app_name
end
on development mode no problem, but in production values are not
accessible
in models.
also tried to use Thread.current, same result, on production does not
work.
Vasily
On Monday, April 8, 2013 5:41:05 PM UTC+1, Vasili Samiev wrote:
class App < ActiveRecord::Base
attr_accessible :active, :name
cattr_accessor :app_id, :app_name
end
on development mode no problem, but in production values are not
accessible in models.
also tried to use Thread.current, same result, on production does not work.
I suspect the problem is that in development the model that uses
default_scope is only needed at the point that it is used, and at that
point App.app_id will have been set. In production however all your
models
are loaded up front. Depending on when/how you set app_id, the model be
setting up its default scope before you sett App.app_id. You could try
using the lambda form of default_scope (personally I’ve always found
default scope to be tricky to work with)
Fred