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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:55:30+00:00 2026-05-25T12:55:30+00:00

Mongoid::Paranoia adds a default scope to the model which generates the criteria #<Mongoid::Criteria selector:

  • 0

Mongoid::Paranoia adds a default scope to the model which generates the criteria

#<Mongoid::Criteria
  selector: {:deleted_at=>{"$exists"=>false}},
  options:  {},
  class:    Line,
  embedded: false>

I can find deleted documents with Model.deleted which generates,

#<Mongoid::Criteria
  selector: {:deleted_at=>{"$exists"=>true}},
  options:  {},
  class:    Line,
  embedded: false>

How can i override this so i can search both deleted and non-deleted documents.

PS Model.unscoped does not work

  • 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-25T12:55:31+00:00Added an answer on May 25, 2026 at 12:55 pm

    Try this(its kind of hack):

    class User
      include Mongoid::Document
      include Mongoid::Paranoia
    
      def self.ignore_paranoia
        all.tap {|criteria| criteria.selector.delete(:deleted_at)}
      end
    end
    
    # ignore paranoia is defined on model, so can't chain it to criteria or scopes
    # but it returns criteria, so can chain other scope and criteria to it
    User.ignore_paranoia.some_scope.where(:whatever => "my_custom_value")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model: class SimpleAction include Mongoid::Document field :set_date, :type => Date and
I have a Mongoid model that looks like this: class V1Cache include Mongoid::Document field
class Account include Mongoid::Document include Geocoder::Model::Mongoid geocoded_by :zip devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable,
I have the following Mongoid model... class Event include Mongoid::Document include Mongoid::Timestamps::Created include Mongoid::Timestamps::Updated
Model: class Plan include Mongoid::Document # Fields field :name, type: String # Relationships references_many
I've a mongoid model and method like the following : class Category include Mongoid::Document
Using Mongoid 2.4.5 on Rails 3.2.1 I have a Model Book that has_many :pages
I've encountered some problems with MongoID. I have three models: require 'mongoid' class Configuration
class Report include Mongoid::Document embeds_many :figures end class Figure include Mongoid::Document embedded_in :report field
I have the following: class Email include ::Mongoid::Timestamps include ::Mongoid::Document field :email_address, :type =>

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.