Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Changed find_first_model to cope with Mongoid 3.0.0 #41

Closed
wants to merge 2 commits into from

4 participants

@julescopeland

Klass.first(conditions) no longer works in Mongoid 3 (it breaks with an ArgumentError).

Updated the method to stop it raising errors. (It should still work in previous versions too).

@ianwhite
Owner

Many thanks!

@jondkinney

Looks to be a duplicate of #47 (I know, this one was created first :) However, I recommend closing this and merging #47 as it has some additional code.

@chewi
Collaborator

Agreed.

@chewi chewi closed this
@chewi
Collaborator

Strike that, reverse it. #47 was for ActiveRecord, this is for Mongoid.

@chewi chewi reopened this
@jondkinney

Aaaah! Sorry. The code is the exact same, but it's in different files. I didn't notice that!

Do we need to update https://github.com/julescopeland/pickle/blob/master/lib/pickle/adapters/mongoid.rb#L35 too? Seems like it could be:

klass.all(conditions)
@chewi
Collaborator

Already on it. Fixed in a backwards-compatible way.

@chewi chewi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/pickle/adapters/mongoid.rb
View
2  lib/pickle/adapters/mongoid.rb
@@ -27,7 +27,7 @@ def self.get_model(klass, id)
# Find the first instance matching conditions
def self.find_first_model(klass, conditions)
- klass.first(:conditions => conditions)
+ klass.where(conditions).first
end
# Find all models matching conditions
Something went wrong with that request. Please try again.