Anurag
Anurag

Reputation: 1016

can we OR the scopes in scope builder?

I am using ryanb-scope-builder and I am facing following issue.

def self.search(options)
  scope_builder do |builder|
    builder.released.visible
    builder.cheap if options[:cheap]
  end
end

This generates query which has :

builder.released.visible *AND* builder.cheap if options[:cheap]

Whereas I want scope to be OR'ed like

builder.released.visible *OR* builder.cheap if options[:cheap]

Is there any scope builder gem which can solve this problem ?? thanks

Upvotes: 1

Views: 480

Answers (1)

apneadiving
apneadiving

Reputation: 115541

I don't know this scope builder but generally, OR queries are made with Arel.

Have a look here: ActiveRecord OR query

Besides, I doubt this gem is that useful:

  • scopes are natively easy to chain

  • the last commit was in 2009

Upvotes: 2

Related Questions