0
我正在使用acts_as_tenant
寶石,它在我的模型中注入默認範圍。太陽黑子搜索 - 忽略默認範圍
我也用太陽黑子搜索,像這樣:
Article.search do
with(:organization_id, ActsAsTenant.current_tenant.id)
fulltext params[:search]
end
Article
模型的作用範圍,這樣即使我不尋求通過當前租戶ID我只會得到正確的結果(只是全部會離開)。
現在,問題:
如果在某些情況下,我想忽略默認範圍從acts_as_tenant
來我怎麼能做到這一點Solr中?這是行不通的:
Article.unscoped.search do
with(:organization_id, 999)
fulltext params[:search]
end
它會生成不正確的SQL:
Article Load (34.2ms) SELECT `articles`.* FROM `articles` WHERE `articles`.`id` IN (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32) AND `articles`.`organization_id` = 1
其中organization_id
是當前租戶的ID
TL; DR:我怎麼忽略了與搜索時默認範圍太陽黑子?