2014-07-15 5 views
0

태그로 주문을 검색하고 싶지만 태그는 고객과 연관되어 있습니다 .... Ransack으로 가능합니까?멀리 떨어진 테이블에 대한 Ransack 검색?

Order.rb

Class Order < ActiveRecord::Base 
belongs_to :customer 
.... 

Customer.rb

Class Customer < ActiveRecord::Base 
has_many :orders 
has_many :customers_tags 
has_many :tags, through: :customers_tags 
.... 

Tag.rb

Class Tag < ActiveRecord::Base 
has_many :customers_tags 
has_many :customers, through: :customers_tags 
.... 

답변

0

예, 여러 연결을 통해 검색 할 수 있습니다. 협회 이름과 마찬가지로 참조하십시오 (has_many의 복수형, belongs_to의 단수). 필드 fieldname 검색 귀하의 예제에서 그래서

, 다음을 사용 :

customer_tags_fieldname_cont

(검색 할 어떤 필드 fieldname를 교체합니다.)

관련 문제