Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 以acts\ U作为\ U租户的范围界定帐户模型?_Ruby On Rails_Scope_Multi Tenant_Acts As Tenant - Fatal编程技术网

Ruby on rails 以acts\ U作为\ U租户的范围界定帐户模型?

Ruby on rails 以acts\ U作为\ U租户的范围界定帐户模型?,ruby-on-rails,scope,multi-tenant,acts-as-tenant,Ruby On Rails,Scope,Multi Tenant,Acts As Tenant,我正在使用子域上键入的充当租户,希望“租户”能够更改其帐户记录(更改其子域),但看不到任何其他人的条目 将account\u id列添加到与account.id具有相同id的account中,并创建帐户模型 acts_as_tenant(:account) 工作,但感觉恶心!另外,这意味着我不能使用config.require_tenant=true初始值设定项,因为当租户尚未设置时,我试图访问一个租户模型以设置当前租户,这自然不起作用 我确信我做这件事完全是错误的,正确的解决方案是显而易见的

我正在使用子域上键入的
充当租户
,希望“租户”能够更改其帐户记录(更改其子域),但看不到任何其他人的条目

将account\u id列添加到与account.id具有相同id的account中,并创建帐户模型

acts_as_tenant(:account)
工作,但感觉恶心!另外,这意味着我不能使用config.require_tenant=true初始值设定项,因为当租户尚未设置时,我试图访问一个租户模型以设置当前租户,这自然不起作用


我确信我做这件事完全是错误的,正确的解决方案是显而易见的,但是睡眠障碍阻止了我看到光明。感谢您的帮助

租户或帐户所有者只需要访问一个帐户,即他自己的帐户

我们要做的是在accounts表中添加一列,名为
owner\u id
,其中包含拥有该帐户的用户的id

然后在accounts\u controller中,我们明确检查:

before_filter current_account.is_owned_by?(current_user)
希望这有帮助