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

  • SEARCH
  • Home
  • 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 6376631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:46:11+00:00 2026-05-25T01:46:11+00:00

Rails 2.3.11 application Mongoid 1.9.2 (latest legacy branch) Since there’s no documentation for Mongoid

  • 0

Rails 2.3.11 application

Mongoid 1.9.2 (latest “legacy” branch)

Since there’s no documentation for Mongoid 1.X branch anymore, I’m struggling with what I’ve got
configured wrong in this example. It seems I’m not querying an embedded document correctly. How
should I be doing it instead?

class GraphLink
  include Mongoid::Document  
  embedded_in :graph_pages, :inverse_of => :graph_links  
end 

class GraphInlink
  include Mongoid::Document  
  embedded_in :graph_pages, :inverse_of => :graph_inlinks  
end

class GraphPage
  include Mongoid::Document

  embeds_many :graph_links
  embeds_many :graph_inlinks

  def add_relationship(link) 
    unless has_link?(url)
      self.graph_links << GraphLink.new(link)
      destination_page = GraphPage.where(:url => link[:url]).first
      destination_page.graph_links << GraphInlinks.new(link)
      destination_page.save
      self.save
    end
  end

  def has_link?(url)
    graph_links.where(:url => url).count > 0
  end

end

At the console, I type

a = GraphPage.new(page_data_1)
a.add_relationship(link1)

And it returns

Error : NoMethodError: undefined method `where' for BSON::OrderedHash:0x00000114c1e8e0 

with the error being the “has_link?” query.

Help!

  • 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-05-25T01:46:12+00:00Added an answer on May 25, 2026 at 1:46 am

    I’m going to guess that you can’t compose queries like that. Perhaps try

    def has_link?(url)
      graph_links.any? { |doc| doc.url == url }
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an application with Rails 3 and MongoDB(mongoid adapter). I am struggling
I'm new to rails application. I got connection with mongodb using mongoid. I generated
is there a sample rails application that uses a sign on with google approach?
I'm writing a ruby on rails application using mongoid and I'm wondering about the
I am trying to initialise mongoid from a rails 3.2 application using ruby-1.9.2 with
I have a model in a Rails/Mongoid application that I had initially set a
I`m having a problem with search query in Rails 3 application using Mongoid. My
I'm trying to do update_attributes with Mongoid in a Rails 3 application The problem
I use MongoDB in my rails application with Mongoid mapper. But I don't understand
I have some rails application with MongoDB, Mongoid mapper and devise. Аuthorized user can

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.