1

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

Anurag
  • 956
  • 2
  • 8
  • 21
  • This question is duplicate of http://stackoverflow.com/questions/3005488/disjunction-in-activerecord – samuil Aug 01 '11 at 09:02

1 Answers1

2

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

Community
  • 1
  • 1
apneadiving
  • 114,565
  • 26
  • 219
  • 213