Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rails 4: Replaced call to deprecated `with_scope' #358

Closed
wants to merge 1 commit into from

7 participants

Christophe Maximin Nathan Youngman Andres Koetsier Ben Johnson Fernando Guillen Ægir Örn Símonarson Matt Giacomini
Christophe Maximin

As you can see in the official gem rails/activerecord-deprecated_finders, with_scope has been deprecated.

ActiveRecord::Base#with_scope and #with_exclusive_scope are deprecated.
Please use ActiveRecord::Relation#scoping instead. (You can use #merge to merge multiple scopes together.)

This update fixes that problem, by using 'where', 'merge' and 'scoping'.

Nathan Youngman

Does it really take so much code to replace with_scope? :-(

Andres Koetsier

Made the patch a little smaller and created a pull-request #369.

Ben Johnson
Owner

369 was merged in

Fernando Guillen

Can the fixed version be released? :)

Ægir Örn Símonarson

+1 for releasing the fixed version.

Matt Giacomini

I have a client bugging me about all the extra log messages. Any chance we can release this?

Nathan Youngman

Please see #388.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 29, 2013
  1. Christophe Maximin
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/authlogic/session/scopes.rb
13 lib/authlogic/session/scopes.rb
View
@@ -91,7 +91,18 @@ def build_key(last_part)
end
def search_for_record(*args)
- klass.send(:with_scope, :find => (scope[:find_options] || {})) do
+ where_content = nil
+ current_scope = nil
+
+ if scope.has_key?(:find_options)
+ if scope[:find_options].is_a?(Hash) and scope[:find_options].has_key?(:conditions)
+ where_content = scope[:find_options][:conditions]
+ elsif scope[:find_options].is_a?(ActiveRecord::Relation)
+ current_scope = scope[:find_options]
+ end
+ end
+
+ klass.send(:where, where_content).merge(current_scope).send(:scoping) do
klass.send(*args)
end
end
Something went wrong with that request. Please try again.