0
我試圖結合has_scope和ransack。在搜索結果中包含選中的has_scope
這些組件中的每一個都完美地工作。但是,當我試圖合併它們時,它們會相互覆蓋。例如,如果我選擇一個作用域,結果將被適當地過濾,但是一旦我使用來自ransack的search_form來進一步過濾結果,範圍就會被刪除。反過來也是如此。
這是如何實現的?
感謝您的幫助。
請參閱下面的我的嘗試。
has_scope :upward_trending, :type => :boolean
has_scope :downward_trending, :type => :boolean
has_scope :all, :type => :boolean
def index
@has_scope = apply_scopes(Product).all
@q = @has_scope.search(params[:q])
@products = apply_scopes(@q.result.page(params[:page]).per(30))
end