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

The Archive Base Latest Questions

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

I am using Ruby on Rails 3.0.7 and I would like to know when

  • 0

I am using Ruby on Rails 3.0.7 and I would like to know when and why class (@@) and global ($) variables should be used and if in this case those are properly used.

P.S.: I am asking this question because I am having the mentioned case-problem and in an answer is proposed the use of a class variable. I am grateful you can explain me if in that case it is good to use that.

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

    The short answer is: never.

    I’m new to ruby, but I do know this much from other languages: global variables are never thread-safe.

    Along the same lines, avoid the singleton pattern like the plague unless you only ever deal with a unique thread.


    Edit:

    As an aside, googling for ruby dependency injection suggests that Ruby doesn’t need any of it. Well, tell you what. It does.

    Because it was always assumed it doesn’t, there are mountains of gems and libraries and what not out there. They basically assume you only ever have a single thread and IO blocking. Had they not done so from the start, they might have been thread safe and non-blocking instead. But currently, they just aren’t.

    And had they done so, they would have been playing better with event-driven servers too.

    As things stand, it’s a bloody mess.

    Event Machine is not thread-safe. Thin and Goliath aren’t by the same token. Rack-async is basically monkey patching the whole thing. Passenger uses fork and is only smart if you install REE/1.8.7 with rails. Mongrel is thread safe but IO-blocking. Webrick is single-threaded and IO blocking. The list goes on. It’s just messy.

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

Sidebar

Related Questions

I would like to create something like this using ruby on rails. Im not
I am using Ruby on Rails 3 and I would know in which case
I am using Ruby on Rails 3 and I would like to know some
I am using Ruby on Rails 3 and I would like to know what
I'm using Ruby on Rails 2.3.8 and I would like to know how to
I am using Ruby on Rails 3 and I would like to know how
I am using Ruby on Rails 3 and I would like to know some
I am using Ruby on Rails 3 and I would like to know some
I am using Ruby on Rails 3.0.7 and I would like to know how
I am using Ruby on Rails 3.0.7 and I would like to know what

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.