README.rdoc in milia-0.3.2 vs README.rdoc in milia-0.3.7
- old
+ new
@@ -50,10 +50,12 @@
=== Devise setup
* See https://github.com/plataformatec/devise for how to set up devise.
* The current version of milia requires that devise use a *User* model.
=== Milia setup
+
+==== migrations
*ALL* models require a tenanting field, whether they are to be universal or to
be tenanted. So make sure the following is added to each migration
<i>db/migrate</i>
@@ -76,10 +78,11 @@
add_index :tenants_users, :tenant_id
add_index :tenants_users, :user_id
end
end
+==== application controller
add the following line AFTER the devise-required filter for authentications:
<i>app/controllers/application_controller.rb</i>
before_filter :authenticate_user! # forces devise to authenticate user
@@ -88,10 +91,11 @@
catch any exceptions with the following (be sure to also add the designated methods!)
rescue_from ::Milia::Control::MaxTenantExceeded, :with => :max_tenants
rescue_from ::Milia::Control::InvalidTenantAccess, :with => :invalid_tenant
+==== routes
Add the following line into the devise_for :users block
<i>config/routes.rb</i>
devise_for :users do
@@ -124,35 +128,41 @@
acts_as_universal_and_determines_tenant
end # class Tenant
=== Designate universal models
-Add the following acts_as_universal to *ALL* models which are to be universal:
+Add the following acts_as_universal to *ALL* models which are to be universal and
+remove any superfluous
+
+ belongs_to :tenant
+
+which the generator might have generated ( acts_as_tenant will specify that ).
<i>app/models/eula.rb</i>
class Eula < ActiveRecord::Base
acts_as_universal
end # class Eula
-Note that the tenant_id of a universal model will always be forced to nil.
-
=== Designate tenanted models
-Add the following acts_as_tenant to *ALL* models which are to be tenanted:
+Add the following acts_as_tenant to *ALL* models which are to be tenanted and
+remove any superfluous
+
+ belongs_to :tenant
+
+which the generator might have generated ( acts_as_tenant will specify that ).
<i>app/models/post.rb</i>
class Post < ActiveRecord::Base
acts_as_tenant
end # class Post
-Note that the tenant_id of a tenanted model must always match the current
-valid tenant.
=== Exceptions raised
Milia::Control::InvalidTenantAccess
Milia::Control::MaxTenantExceeded
@@ -197,10 +207,11 @@
== Cautions
* Milia designates a default_scope for all models (both universal and tenanted). From Rails 3.2 onwards, the last designated default scope overrides any prior scopes.
* Milia uses Thread.current[:tenant_id] to hold the current tenant for the existing Action request in the application.
* SQL statements executed outside the context of ActiveRecord pose a potential danger; the current milia implementation does not extend to the DB connection level and so cannot enforce tenanting at this point.
-
+* The tenant_id of a universal model will always be forced to nil.
+* The tenant_id of a tenanted model will be set to the current_tenant of the current_user upon creation.
== Contributing to milia
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet