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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:22:19+00:00 2026-06-16T02:22:19+00:00

I use in-memory database for testing. The schema is reloaded in every test. Recently

  • 0

I use in-memory database for testing. The schema is reloaded in every test.

Recently my rspec complains that a table is not found. The reason is that a scope is referencing another model at load time.

class Item
  scope :public, where(:store_id => Store.public_store_ids())

class Store
  def self.public_store_ids
    self.public.pluck(:id)

The problem is that, during the initializing when item model is loaded in the memory, the schema for store table has not been loaded yet, but my scope will try to query the public store ids, which results in the “table not found” error.

How can I make my item scope to evaluate dynamically at runtime? I didn’t want to use join because it can slow down my query, but would it be my only way?

  • 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-16T02:22:20+00:00Added an answer on June 16, 2026 at 2:22 am

    I realized that I can just make it a class method so it is evaluated at run time

    def self.public
      store_ids = BeautyStreet::Store.public_store_ids()
      where(:store_id => store_ids)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use sqlite memory database for all my testing and Postgresql for
I want to use an in-memory database to test my application, but it needs
I use the in-memory database that comes with Play Framework, when I have db=mem
We would like to use H2 in-memory database for automated testing of our web-applications.
I'm trying to use an in-memory SQLite database to test my data layer which
For unit testing I use a derby in-memory database. Is there any chance to
I want to use an in-memory database to test my application, but it needs
We use hypersonic in memory database for our DAO junit tests. The problem is
I know that SQL server use memory cache for the all operations by loading
When unit testing, is it a must to use a database when testing CRUD

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.