Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:52:39+00:00 2026-06-07T11:52:39+00:00

The MongoID docs seem to be pretty clear that I should be able to

  • 0

The MongoID docs seem to be pretty clear that I should be able to run this and have it work:

Band.find_by(name: "Photek")

but at least with MongoID 2.4.11 this gives me a NoMethodError.

This, on the other hand, works:

Band.find(name: "Photek")

It’s easy enough to change find_by to find, but I’m confused what’s going on. Is this a case where my gem version is behind the docs, or what?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:52:41+00:00Added an answer on June 7, 2026 at 11:52 am

    The Mongoid docs now show you version 3 by default (it’s an RC). You want to look at the docs here for Mongoid 2.

    On find vs find_by, this is from the upgrade guide for Mongoid 2 -> 3:

    Model.find and model.relation.find now only take a single or multiple ids. Model.first, Model.last also no longer take arguments. For these use Model.find_by instead.

    IOW:

    Mongoid 2:

    Band.find(some_id)
    Band.find(name: "Billy Talent")
    

    Mongoid 3:

    Band.find(some_id)
    Band.find(some_id, some_other_id)
    Band.find_by(name: "Billy Talent")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that looks like this: class SearchService include Mongoid::Document key :name,
I have a Mongoid model that looks like this: class V1Cache include Mongoid::Document field
Using Mongoid 2.4.5 on Rails 3.2.1 I have a Model Book that has_many :pages
I have a Sinatra/Mongoid application and I noticed that my mongoid model/object does not
I have a mongoid document which embeds other documents with a relation like this:
Just trying out Mongoid at the moment, I've run into an issue that's probably
I'd like to use the Mongoid criteria methods ( http://mongoid.org/docs/querying/criteria.html ). I have a
I have several Mongoid models that I'm running mapreduce on, and I'd like to
I have a few Mongoid model classes that all have a :datetime field. I
I've encountered some problems with MongoID. I have three models: require 'mongoid' class Configuration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.