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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:00:14+00:00 2026-06-15T19:00:14+00:00

I have model with default_scope: class Campaign < ActiveRecord::Base default_scope where(campaigns.status != ?, archive)

  • 0

I have model with default_scope:

class Campaign < ActiveRecord::Base
  default_scope where("campaigns.status != ?", "archive")
end

Then I need disable this scope in show action:

@campaign = Campaign.unscoped.find(params[:id])

But I see Couldn't find Campaign with id=1 [WHERE (campaigns.status != 'archive')]

Then I tried the same solution in rails console:

 Campaign.unscoped.find(1)
 SELECT `campaigns`.* FROM `campaigns` WHERE `campaigns`.`id` = 1 LIMIT 1 

And all works fine, what I doing wrong in controller?

UPDATE:

Campaign.unscoped{
}

Did not work too. It seems @campaign determined elsewhere and earlier, because I delete all rows from my show action and now it looks like:

def show
end

And I am still getting this error: Couldn't find Campaign with id=1 [WHERE (campaigns.status != 'archive')]

I find out this tricks in load_and_authorize_resource, but how can I fix it?

  • 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-15T19:00:16+00:00Added an answer on June 15, 2026 at 7:00 pm

    It seems like what you have would work fine, according to the documentation. However, it is mentioned here that it is recommended to use the block form of unscoped. You might give that a try and see if it resolves the problem.

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

Sidebar

Related Questions

We have the following model: payment.rb: class Payment < ActiveRecord::Base has_many :currencies default_scope :include
If I have an ActiveRecord::Base model with a default-scope: class Foo < ActiveRecord::Base default_scope
I have a simple models class Item < ActiveRecord::Base has_many :parts end class Part
I have models set up similar to this: class Book < ActiveRecord::Base has_many :histories,
I have following models: class Category < ActiveRecord::Base has_many :items default_scope where(:enabled => true,
I'm using Rails 3. I have 3 models: class Deal < ActiveRecord::Base has_many :wishes,
I have a User model that has the following default_scope: default_scope where(account_id: Account.current_account.id) If
If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}
I have model public class UploadOptionModel { public UploadOptionModel() { OutputFormat = outputFormatList.Select(i =>
Let's say I have a set of Django Models: class Article(models.Model): title = models.CharField(max_length=100,

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.