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 6964909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:59:06+00:00 2026-05-27T15:59:06+00:00

self here stands for Contact model. This query will find all completed tasks for

  • 0

“self” here stands for Contact model.
This query will find all completed tasks for a contact.
The Task model has a field/key :assigned_contacts of type Array.
So the query is searching inside the Array.

def assigned_tasks_completed
  self.company.tasks.all(:assigned_contacts => self.id.to_s, :completed => true)
end

How to do this in Mongoid?

Another question:
The equivalent in Mongoid of @contact.set(:a -> a, :b -> b, :c -> c) is update_attributes!

But there is also a method set in Mongoid.
What is the difference between set & update_attributes! in Mongoid ?

  • 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-27T15:59:06+00:00Added an answer on May 27, 2026 at 3:59 pm

    I assume your tasks is a separate document. So you can just replace all with where, it will work

    def assigned_tasks_completed
      self.company.tasks.where(:assigned_contacts => self.id.to_s, :completed => true)
    end
    

    For your another question,

    Both mongoid set & update attributes are internally uses mongodb $set. But the difference is mongoid set is only accepts single field update, update_attributes accepts multiple.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The base class has this: def _management_form(self): # code here return form management_form =
So, I know this has been done to death but all the answers I've
Here's my code: UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightButtonPressed)]; [self.navigationItem setLeftBarButtonItem:leftButton]; [leftButton
Here is a related manager I wrote: class PortfolioItemManager(models.Manager): use_for_related_fields = True def extended(self):
here's my code: ViewController *vc = [[ViewController alloc] initWithNibName:@TableView bundle:nil]; [self.navigationController presentModalViewController:vc animated:YES]; //[self
here the following code is used to view the present modal view controller. [[self
Reading up on WCF we have self hosting option available , one limitation here
// A : Parent @implementation A -(id) init { // change self here then
My app crashes when the control comes over here [self loadNextList] . I am
Here are some models I am trying to load data for: class School(models.Model): name

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.