Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.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 与基于关系表(Rails 2.3.5)的条件有多个贯穿关系_Ruby On Rails - Fatal编程技术网

Ruby on rails 与基于关系表(Rails 2.3.5)的条件有多个贯穿关系

Ruby on rails 与基于关系表(Rails 2.3.5)的条件有多个贯穿关系,ruby-on-rails,Ruby On Rails,我的关系如下 companies_employee.rb belongs_to :employee belongs_to :company validates_presence_of :role employee.rb has_many :companies_employees has_many :companies, :through => :companies_employees company.rb has_many :companies_employees has_many :

我的关系如下

companies_employee.rb
belongs_to :employee
belongs_to :company
validates_presence_of :role

employee.rb
has_many :companies_employees
has_many :companies, :through => :companies_employees

company.rb
has_many :companies_employees
has_many :managers, :through => :companies_employees, :source => :employee, conditions => {:role => "Manager"}
has_many :owners, :through => :companies_employees, :source => :employee, :conditions => {:role => "Owner"}
我的问题是,当它检查条件时,它试图在employees表中查找role列,但role列在companys\u employees表中。
有没有办法让它使用此表中的内容作为条件?

尝试以下方法:

has_many :managers, :through => :companies_employees, :source => :employee, conditions => ["employees.role = 'Manager"]
has_many :owners, :through => :companies_employees, :source => :employee, conditions => ["employees.role = 'Owner"]

这有着完全相同的问题,它仍然试图在employees表中查找row列,而我想要的是在:companys\u employees表中查找role列。那么,将employees.role更改为companys\u employees.role。