Skip to content

Commit

Permalink
Make it possible to get good polymorphic joins
Browse files Browse the repository at this point in the history
Actually getting polymorphic joins to work correctly will require
either explicitly specifying the master branch of the `ransack`
project (commit c9cc20de9e0f or something with equivalent
functionality) in the project `Gemfile` or the `ransack` project
releasing a new 2.x (> 2.3.2) version with that functionality.

Addresses most of the Active Record 5.2.x (>= 5.2.1) problems in
rzane#97.  The only remaining issues are around inner
joins after left joins.
  • Loading branch information
rtweeks committed Sep 1, 2020
1 parent f071951 commit eba126a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ else
gem 'activerecord', ENV['AR']
end

case ENV.fetch('RANSACK', 'latest')
when 'latest'
gem 'ransack', require: false
when 'master'
gem 'ransack', github: 'activerecord-hackery/ransack', require: false
else
ENV['RANSACK'].split('#').tap do |repo, branch|
opts = {git: repo, require: false}
opts[:branch] = branch if branch
gem 'ransack', opts
end
end

gem 'bump'

group :test do
Expand Down
2 changes: 1 addition & 1 deletion baby_squeel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}')

spec.add_dependency 'activerecord', '>= 4.2.0'
spec.add_dependency 'polyamorous', '~> 2.3.0'
spec.add_dependency 'ransack', '~> 2.3'
spec.add_dependency 'join_dependency', '~> 0.1.4'

spec.add_development_dependency 'bundler', '~> 2'
Expand Down
7 changes: 6 additions & 1 deletion lib/baby_squeel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require 'active_record'
require 'active_record/relation'
require 'polyamorous'
begin
require 'polyamorous'
rescue LoadError
# Trying loading from 'ransack' as of commit c9cc20de9 (post v2.3.2)
require 'polyamorous/polyamorous'
end
require 'baby_squeel/version'
require 'baby_squeel/errors'
require 'baby_squeel/active_record/base'
Expand Down

0 comments on commit eba126a

Please sign in to comment.