Skip to content

Instantly share code, notes, and snippets.

@the8472
Last active December 25, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the8472/6903452 to your computer and use it in GitHub Desktop.
Save the8472/6903452 to your computer and use it in GitHub Desktop.
gem 'rails', "~> 3.2"
gem 'squeel', "~> 1.1"
gem 'sqlite3'
require "active_record"
require "squeel"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
class A < ActiveRecord::Base
belongs_to :poly, :polymorphic => true
end
class B < ActiveRecord::Base
has_many :c, :as => :poly
has_many :xxx, :class_name => "C", :as => :poly
end
class C < ActiveRecord::Base
belongs_to :poly, :polymorphic => true
end
class E < ActiveRecord::Base
end
puts A.joins{[poly(B).xxx, poly(E).outer]}.where{poly(B).xxx.column.in(["value1","value2"])}.debug_sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment