From f9110ad4cb3958ebcb7734f972360781f47055bb Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 13 Dec 2013 08:27:50 -0800 Subject: [PATCH] No more `with_default_scope` on Rails master, see https://github.com/rails/rails/commit/94924dc32baf78f13e289172534c2e71c9c8cade --- lib/freedom_patches/rails_security_fixes.rb | 4 +++- lib/trashable.rb | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/freedom_patches/rails_security_fixes.rb b/lib/freedom_patches/rails_security_fixes.rb index 7650af2d4f9..a0ff8f6bc03 100644 --- a/lib/freedom_patches/rails_security_fixes.rb +++ b/lib/freedom_patches/rails_security_fixes.rb @@ -45,7 +45,9 @@ unless rails4? class Relation def where_values_hash - equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node| + values = rails_master? ? where_values : with_default_scope.where_values + + equalities = values.grep(Arel::Nodes::Equality).find_all { |node| node.left.relation.name == table_name } diff --git a/lib/trashable.rb b/lib/trashable.rb index 5d0e74b2850..d69f3ff215f 100644 --- a/lib/trashable.rb +++ b/lib/trashable.rb @@ -15,7 +15,13 @@ module Trashable # # with this in place Post.limit(10).with_deleted, will work as expected # - scope = rails4? ? self.all.with_default_scope : self.scoped.with_default_scope + scope = if rails_master? + self.all + elsif rails4? + self.all.with_default_scope + else + self.scoped.with_default_scope + end scope.where_values.delete(with_deleted_scope_sql) scope