Permalink
Browse files

Clean up controller extensions. Update changelog.

  • Loading branch information...
1 parent 88dd110 commit 84372035ca2630edc7a8633767e2ca3604d0d842 @ErwinM committed Feb 11, 2013
Showing with 7 additions and 38 deletions.
  1. +3 −1 CHANGELOG.md
  2. +4 −37 lib/acts_as_tenant/controller_extensions.rb
View
4 CHANGELOG.md
@@ -1,7 +1,9 @@
0.3.0
-----
-* You can now raise an exception if a query on a scope model is made without a tenant set. Adding `require_tenant` to your application controller will invoke this behavior.
+* You can now raise an exception if a query on a scope model is made without a tenant set. Adding an initializer that sets config.require_tenant to true will accomplish this. See readme for more details.
* `ActsAsTenant.with_tenant` will now return the value of the block it evaluates instead of the original tenant. The original tenant is restored automatically.
+* acts_as_tenant now raises standard errors which can be caught individually.
+* `set_current_tenant_to`, which was deprecated some versions ago and could lead to weird errors, has been removed.
0.2.9
View
41 lib/acts_as_tenant/controller_extensions.rb
@@ -5,26 +5,19 @@ module ControllerExtensions
# it up in the tenant-model passed to the method (defaults to Account). The method will
# look for the subdomain in a column referenced by the second argument (defaults to subdomain).
def set_current_tenant_by_subdomain(tenant = :account, column = :subdomain )
- self.class_eval do
- cattr_accessor :tenant_class, :tenant_column
- attr_accessor :current_tenant
- end
-
- self.tenant_class = tenant.to_s.camelcase.constantize
- self.tenant_column = column.to_sym
+ @tenant_class = tenant.to_s.camelcase.constantize
+ @tenant_column = column.to_sym
self.class_eval do
before_filter :find_tenant_by_subdomain
-
helper_method :current_tenant
private
def find_tenant_by_subdomain
- ActsAsTenant.current_tenant = tenant_class.where(tenant_column => request.subdomains.first).first
+ ActsAsTenant.current_tenant = @tenant_class.where(@tenant_column => request.subdomains.first).first
@current_tenant_instance = ActsAsTenant.current_tenant
end
- # helper method to have the current_tenant available in the controller
def current_tenant
ActsAsTenant.current_tenant
end
@@ -41,33 +34,7 @@ def set_current_tenant(current_tenant_object)
ActsAsTenant.current_tenant = current_tenant_object
end
- private
- # helper method to have the current_tenant available in the controller
- def current_tenant
- ActsAsTenant.current_tenant
- end
- end
- end
-
- def require_tenant
- ActsAsTenant.require_tenant
- end
-
- # this method allows manual setting of the current_tenant by passing in a tenant object
- #
- def set_current_tenant_to(current_tenant_object)
- self.class_eval do
- cattr_accessor :tenant_class
- attr_accessor :current_tenant
- before_filter lambda {
- ActiveSupport::Deprecation.warn "set_current_tenant_to is deprecated and will be removed from Acts_as_tenant in a future releases, please use set_current_tenant_through_filter instead.", caller
- @current_tenant_instance = ActsAsTenant.current_tenant = current_tenant_object
- }
-
- helper_method :current_tenant
-
- private
- # helper method to have the current_tenant available in the controller
+ private
def current_tenant
ActsAsTenant.current_tenant
end

0 comments on commit 8437203

Please sign in to comment.