ruby 在rails中查询关联

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 在rails中查询关联相关的知识,希望对你有一定的参考价值。

@shops = Shop.includes(concept: [:chain]).where(where_clause_map).order("#{attribute} #{ordering}").limit(params[:rowCount]).offset(offset)

Where:

Shop includes concept and in turn concept includes chain

and 

where_clause_map looks like: {"id" => "[1,2]", "shop_concepts" => "1" ,"shop_chains.id"=> "1"}

NOTE: Using an array as in: "id" => "[1,2]" , causes the query to run as id IN (1, 2)

以上是关于ruby 在rails中查询关联的主要内容,如果未能解决你的问题,请参考以下文章