acts_as_tenant 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ 0.2.6
2
+ -----
3
+ * Fixed a bug with resolving the tenant model name (thx devton!)
4
+ * Added support for using relations: User.create(:account => Account.first) now works, while it wouldn't before (thx bnmrrs)
5
+
1
6
  0.2.5
2
7
  -----
3
- * Added Rails 3.2 compatibility
8
+ * Added Rails 3.2 compatibility (thx nickveys!)
4
9
 
5
10
  0.2.4
6
11
  -----
@@ -10,7 +10,7 @@ module ActsAsTenant
10
10
  attr_accessor :current_tenant
11
11
  end
12
12
 
13
- self.tenant_class = tenant.to_s.capitalize.constantize
13
+ self.tenant_class = tenant.to_s.camelcase.constantize
14
14
  self.tenant_column = column.to_sym
15
15
 
16
16
  self.class_eval do
@@ -53,15 +53,15 @@ module ActsAsTenant
53
53
  if new_record?
54
54
  write_attribute(fkey, integer)
55
55
  else
56
- raise "#{fkey} is immutable!"
56
+ raise "#{fkey} is immutable! [ActsAsTenant]"
57
57
  end
58
58
  end
59
59
 
60
60
  define_method "#{association}=" do |model|
61
61
  if new_record?
62
- write_attribute(association, model)
62
+ super(model)
63
63
  else
64
- raise "#{association} is immutable!"
64
+ raise "#{association} is immutable! [ActsAsTenant]"
65
65
  end
66
66
  end
67
67
 
@@ -76,14 +76,14 @@ module ActsAsTenant
76
76
  validates_each a.foreign_key.to_sym do |record, attr, value|
77
77
  # Invalidate the association unless the parent is known to the tenant or no association has
78
78
  # been set.
79
- record.errors.add attr, "is invalid (Acts_as_Tenant)" unless value.nil? || association_class.where(:id => value).present?
79
+ record.errors.add attr, "is invalid [ActsAsTenant]" unless value.nil? || association_class.where(:id => value).present?
80
80
  end
81
81
  end
82
82
  end
83
83
  end
84
84
 
85
85
  def validates_uniqueness_to_tenant(fields, args ={})
86
- raise "ActsAsTenant::validates_uniqueness_to_tenant: no current tenant" unless respond_to?(:is_scoped_by_tenant?)
86
+ raise "[ActsAsTenant] validates_uniqueness_to_tenant: no current tenant" unless respond_to?(:is_scoped_by_tenant?)
87
87
  tenant_id = lambda { "#{ActsAsTenant.tenant_class.to_s.downcase}_id"}.call
88
88
  args[:scope].nil? ? args[:scope] = tenant_id : args[:scope] << tenant_id
89
89
  validates_uniqueness_of(fields, args)
@@ -1,3 +1,3 @@
1
1
  module ActsAsTenant
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-28 00:00:00.000000000Z
12
+ date: 2012-02-09 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Integrates multi-tenancy into a Rails application in a convenient and
15
15
  out-of-your way manner