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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:07:28+00:00 2026-05-23T15:07:28+00:00

I’m having trouble understanding how singular resource works in Rails. In particular, how does

  • 0

I’m having trouble understanding how singular resource works in Rails.

In particular, how does Rails know which singular belongs to me when I access a Rails app across a session; and how does the Rails app make sure there are no conflicts when there are many users?

Does the server somehow map requests (based on IP) to unique Rails processes? And each process correspond to a single IP and when a previously unknown IP connects a new Rails process starts?

If so, how is it possible that I can log in as multiple users (using different browsers) on the same machine?

And how is it possible that I can go into multiple sessions with multiple singular resources on localhost running Webrick, if webrick is single threaded?

Any explanation or link to resources that I can read is appreciated.

  • 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-23T15:07:28+00:00Added an answer on May 23, 2026 at 3:07 pm

    The only thing the singular resource does is changes the routes that Rails sets up. So it basically removes all the :ids from your routes (and it drops the index route because it makes no sense for a singular resource and is now the same as the show route).

    Rails doesn’t do anything magical for singular resources, no. You need to take care of that in your app. You’ll generally do this by using the session to store an id. Your session maps a cookie that it sends to the browser to a session instance stored by Rails in either a file, the DB, or something like memcache, so multiple app processes on the server are all using a common session store.

    So, for example – after a user logs in, you’ll store his user_id in the session and you’ll have a before_filter in the controller of your singular resource (and all other controllers that need it) that retrieves that user_id from the session and retrieves the User record using standard ActiveRecord finders.

    If you want to log in as multiple users then you need some sort of scope/namespace identifier as well as the user_id, but really it’d be best to use one of the authentication gems here – many of which have some sort of scope mechanism.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

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.