Created
November 19, 2010 13:07
-
-
Save kernow/706491 to your computer and use it in GitHub Desktop.
Mongoid criteria problem?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I would expect all of the following to return the same results | |
# Works as expected | |
Article.find(:first, :conditions => { :slug => 'blah', :published => true }) | |
# On latest beta gem errors with ArgumentError: wrong number of arguments (2 for 0..1) | |
# Works on latest github master commi | |
Article.where(:published => true).find(:first, :conditions => { :slug => 'blah' }) | |
# On latest beta gem erros with ArgumentError: wrong number of arguments (2 for 0..1) | |
# Works on latest github master commi | |
Article.published.find(:first, :conditions => { :slug => 'blah' }) | |
# On latest beta gem errors with ArgumentError: wrong number of arguments (1 for 0) | |
# Works on latest github master commi | |
Article.published.first(:conditions => { :slug => 'blah' }) | |
# Works on latest github master commit | |
Article.published.where(:slug => 'blah').first | |
# Article Model | |
class Article | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :title | |
field :slug | |
field :body | |
field :published, :type => Boolean, :default => false | |
validates_presence_of :title, :body | |
before_save :set_slug | |
scope :published, :where => { :published => true }, :order_by => :created_at.desc | |
def set_slug | |
self.slug = title.parameterize | |
end | |
def to_param | |
slug | |
end | |
end |
I believe this was fixed in a later version
:'(
Having the same issue on 2.4.7.
Any chance you were using the mongoid_slug gem?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kernow did you ever find the solution to this problem?