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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:18:31+00:00 2026-06-06T22:18:31+00:00

I am getting this error While running this LoadError: Expected /home/user/Desktop/Tripurari/myapp/app/models/host.rb to define Host##

  • 0

I am getting this error While running this

LoadError: Expected /home/user/Desktop/Tripurari/myapp/app/models/host.rb to define Host##

But every thing on it’s place. Can some one tell me what the exact problem is below method.

def self.check_all(keyword)
  memo_mutex = Mutex.new
  memo       = {}
  threads    = []
  name       = keyword.keyword
  SITES.each do |site_and_options|
    threads << Thread.new do
      @host = Host.find_or_create_by_name(site)
      if keyword.unavailable_usernames.find_by_host_id(@host.id)
        memo[@host.name] = true
      else
        memo[@host.name] = false
      end
    end
  end
  threads.each { |t| t.join }
  memo
end
  • 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-06T22:18:32+00:00Added an answer on June 6, 2026 at 10:18 pm

    The issue is probably caused by the autoloader. If the Host class is not yet loaded when first entering the loop where you create a couple of new threads, it is autoloaded, i.e. Rails searches the loadpath for a file matching the naming conventions and requires it.

    This process is not threadsave. In your case, as you are creating servral threads in quick succession, each trying to autoload the global class, you get race conditions and strange things happen. Basically, you have two options for tackling this:

    1. You can explicitly load the model before starting your threads by using require 'host' before starting your loop.
    2. Or you can set config.threadsave! in an initializer. This will (among other things) preload all your classes when starting your server. This is preferred as with this, you avoid a truckload of other difficult to debug concurrency issues. For more information about config.threadsafe!, please refer to the excellent article by Aaron Patterson arguing it should be removed altogether in Rails 4.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error while running my app on the device.I have installed
I am getting this weird error while running cucumber test: ERROR Mongo::OperationFailure: Database command
I have a problem running RoR project. I am getting this error while running
I am getting this error while running a hadoop pipes program. The program compiles
I'm getting this error while running tomcat 'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver'. I'm using a combination of
cannot load c:/PHP5/php5apache2_2.dll into server I am getting this error while running apache 2.2
I am getting this error when running ./manage.py migrate app_name While loading migration 'whatever.0001_initial':
I recently started getting this error while running gems or bundler. The only thing
I am getting this error while running my code: Error using ==> mldivide Matrix
hiii i am getting this error while running test for my fluent nhibernate application.

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.