On Monday, April 8, 2013 5:41:05 PM UTC+1, Vasili Samiev
wrote:>
> 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.
>
>
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
--
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/msg/rubyonrails-talk/-/4kDJ3TiduEQJ.
For more options, visit https://groups.google.com/groups/opt_out.