1
我試圖做這樣的事情:鏈與哪來的ActiveRecord加入
filter_categorys = params[:filter_categorys]
companies = Company.where('id_category = (?)', filter_categorys).joins(:subsidiary).where('zone = Nuñez')
而且它不工作....
所以,我需要讓我的所有公司有一個id_category並且他們在「區域」內至少有一個子公司。
我想這不是...請幫助! :d
Company.rb:
class Company < ActiveRecord::Base
has_many :subsidiary, :foreign_key => :id_company
has_many :benefit, :foreign_key => :id_company
set_primary_key :id_company
self.table_name = 'tbl_companys'
end
Subsidiary.rb:
class Subsidiary < ActiveRecord::Base
belongs_to :company
set_primary_key :id_subsidiary
self.table_name = 'tbl_subsidiaries'
end
使用'id_category IN(?)'(不相等) – MrYoshiji
謝謝,但問題是試圖獲取對tbl_companys的「區域」列及其對tbl_subsidiaries –