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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:59:48+00:00 2026-05-28T16:59:48+00:00

This is a convoluted example so bear with me: I have a script that

  • 0

This is a convoluted example so bear with me:

I have a script that I routinely use during dev that will wipe out my tables of my dev and test databases, remigrate, then reseed them. Due to my use of triggers in a couple places, I’ve had to use rake db:migrate RAILS_ENV=test to migrate my test database properly.

Everything was fine until I turned config.cache_classes=true on in my test environment. Then when the rake migration ran on an empty database I would get an error about how the table doesn’t exist. Running this with a –trace, I find that its blowing up on one of my objects when it declares a basic scope:

scope :find_by_route_and_date, lambda { |route_id, date|
    {
      :conditions=>{:route_id=>route_id, :schedule_date=>date}
    }
  }

The scope is in a lambda, so it shouldn’t be getting evaluated, but the minute I remove cache_classes, the migration works fine. So, to me it seems like its trying to cache the model, choking on the scope because the table doesn’t exist yet, and never starting the migration.

Am I losing my mind? Anyone else seen this? If I need to wipe my db, do I need to turn caching off, then migrate, then turn it back on?

Rails 3.2, ruby 1.9.2, rake 0.9.2.2

UPDATED:

As requested, here is the stack trace: https://gist.github.com/1705064

The order.rb:179 is the place where my first scope is defined and where it blows up that I listed above.

  • 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-28T16:59:49+00:00Added an answer on May 28, 2026 at 4:59 pm

    This is interesting. My reading of the stack trace is that rails is trying to help you be seeing if whether creating that scope (ie creating a method of the same name) you would be creating trouble by overwriting some existing method.

    This leads active record down respond_to where it thinks that your scope/method name looks a lot like a dynamic finder. It then goes further: as well as looking like a dynamic finder, do all the named attributes exist? This is where it tries to check what columns the non existant table has and everything blows up.

    You could (I think) do one of a few things:

    • before the scope, define a class method with the same name as the scope so as to short circuit the respond_to call (yuck)
    • change your scope name
    • override valid_scope_name

    I’m still not sure why you can’t setup the test db from a schema file, if necessary setting the schema dumper to :sql so that things that active record doesn’t support natively are preserved.

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

Sidebar

Related Questions

Say I have the following: std::unique_ptr<A> pA; pA(new A); In this convoluted example, what
I think this question is better served with an example. I have the following
A more convoluted example of this question is here: child div height of 100%
This is a bit convoluted but I will try to explain as best as
This is starting to vex me. I recently decided to clear out my FTP,
I've just noticed that the long, convoluted Facebook URLs that we're used to now
I'm trying to do something like this (completely synthetic example, because the real code
For example suppose I have a class Vehicle and I wish for a subclass
I have an html page that I am converting over to an asp .net
I have a rails application that serves as an interface to a hybrid of

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.