Closed philsmy closed 8 years ago
thanks for reporting. I also need to see your model setup for Class Tenant.
On Wed, Apr 15, 2015 at 1:00 AM Phil Smy notifications@github.com wrote:
in my tenant I have put the following line:
has_many :monthly_order_summaries, dependent: :destroy
When I destroy the tenant I see this in my logs:
MonthlyOrderSummary Load (0.2ms) SELECT
monthly_order_summaries
.* FROMmonthly_order_summaries
WHERE (monthly_order_summaries.tenant_id = NULL) ANDmonthly_order_summaries
.tenant_id
= 16Obviously this will not work - it is ANDing on two tenant_id selects.
The model looks like this:
class MonthlyOrderSummary < ActiveRecord::Base acts_as_tenant end
— Reply to this email directly or view it on GitHub https://github.com/dsaronin/milia/issues/57.
This happens if I do NOT first set a Tenant (using Tenant.set_current_tenant). If I set a tenant then the first where (previously NULL) will be the id of the set tenant.
Of course, if I set a random tenant and then try to delete the last tenant that doesn't work because the current tenant and last tenant id's are not the same.
On 16 April 2015 at 04:14, Daudi Amani notifications@github.com wrote:
thanks for reporting. I also need to see your model setup for Class Tenant.
On Wed, Apr 15, 2015 at 1:00 AM Phil Smy notifications@github.com wrote:
in my tenant I have put the following line:
has_many :monthly_order_summaries, dependent: :destroy
When I destroy the tenant I see this in my logs:
MonthlyOrderSummary Load (0.2ms) SELECT
monthly_order_summaries
.* FROMmonthly_order_summaries
WHERE (monthly_order_summaries.tenant_id = NULL) ANDmonthly_order_summaries
.tenant_id
= 16Obviously this will not work - it is ANDing on two tenant_id selects.
The model looks like this:
class MonthlyOrderSummary < ActiveRecord::Base acts_as_tenant end
— Reply to this email directly or view it on GitHub https://github.com/dsaronin/milia/issues/57.
— Reply to this email directly or view it on GitHub https://github.com/dsaronin/milia/issues/57#issuecomment-93536412.
Phil Smy - "http://www.philsmy.com" filmsite: http://philsfilmlinks.com twitter: http://twitter.com/psmy facebook: http://facebook.com/philsmy
well of course it won't work; this is a multi-tenanting system; if authorization is not established then it should NOT be possible to destroy tenanted records. So to delete a tenant and have the dependent: destroy work, you must first establish a current_tenant, then destroy the tenant, then change the current_tenant.
On Wed, Apr 15, 2015 at 9:15 PM Phil Smy notifications@github.com wrote:
This happens if I do NOT first set a Tenant (using Tenant.set_current_tenant). If I set a tenant then the first where (previously NULL) will be the id of the set tenant.
Of course, if I set a random tenant and then try to delete the last tenant that doesn't work because the current tenant and last tenant id's are not the same.
On 16 April 2015 at 04:14, Daudi Amani notifications@github.com wrote:
thanks for reporting. I also need to see your model setup for Class Tenant.
On Wed, Apr 15, 2015 at 1:00 AM Phil Smy notifications@github.com wrote:
in my tenant I have put the following line:
has_many :monthly_order_summaries, dependent: :destroy
When I destroy the tenant I see this in my logs:
MonthlyOrderSummary Load (0.2ms) SELECT
monthly_order_summaries
.* FROMmonthly_order_summaries
WHERE (monthly_order_summaries.tenant_id = NULL) ANDmonthly_order_summaries
.tenant_id
= 16Obviously this will not work - it is ANDing on two tenant_id selects.
The model looks like this:
class MonthlyOrderSummary < ActiveRecord::Base acts_as_tenant end
— Reply to this email directly or view it on GitHub https://github.com/dsaronin/milia/issues/57.
— Reply to this email directly or view it on GitHub https://github.com/dsaronin/milia/issues/57#issuecomment-93536412.
Phil Smy - "http://www.philsmy.com" filmsite: http://philsfilmlinks.com twitter: http://twitter.com/psmy facebook: http://facebook.com/philsmy
— Reply to this email directly or view it on GitHub https://github.com/dsaronin/milia/issues/57#issuecomment-93635318.
in my tenant I have put the following line:
has_many :monthly_order_summaries, dependent: :destroy
When I destroy the tenant I see this in my logs:
MonthlyOrderSummary Load (0.2ms) SELECT
monthly_order_summaries.* FROM
monthly_order_summariesWHERE (monthly_order_summaries.tenant_id = NULL) AND
monthly_order_summaries.
tenant_id= 16
Obviously this will not work - it is ANDing on two tenant_id selects.
The model looks like this:
class MonthlyOrderSummary < ActiveRecord::Base acts_as_tenant end
This happens if I do:
Tenant.last.destroy