activerecord-hackery / squeel

Active Record, improved. Live again :)
http://erniemiller.org/2013/11/17/anyone-interested-in-activerecord-hackery/
MIT License
2.4k stars 214 forks source link

Huge problems generating desired query #72

Closed gucki closed 12 years ago

gucki commented 12 years ago

Sorry to bother you with this, but I simply cannot find a solution to make squeel generate my desired query. Here's my code with all the scopes I tried and the exception I got (I used only one at once).

class Offer < ActiveRecord::Base
  def build_scope
    brands = [1,2,3]
    models = [4,5,6]
    scope = scoped
    scope = scope.where{(id.in brands) | (id.in models)} # undefined method `in' for 0:Fixnum
    scope = scope.where{(:id.in brands) | (:id.in models)} # undefined method `in' for :id:Symbol
    scope = scope.where{("id".in brands) | ("id".in models)} # undefined method `in' for "id":String
    scope = scope.where{{:id => brands} | {:id => models}} # Cannot visit Sequel::SQL::BooleanExpression
  end
end

Any help would be really nice :)

gucki commented 12 years ago

Sorry, the problem was a local variable named "id". :-(