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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:59:42+00:00 2026-06-09T22:59:42+00:00

I tried to set the session store to be a ActiveRecordStore. I have made

  • 0

I tried to set the session store to be a ActiveRecordStore. I have made the following changes:

# application.rb
config.action_dispatch.session_store = :active_record_store

# session_store.rb
MyApp::Application.config.session_store :active_record_store
ActiveRecord::SessionStore.session_class = Session

# the session class
class Session < ActiveRecord::SessionStore::Session
  belongs_to :user
  before_save :ensure_user_is_set

  def self.find_by_session_id(session_id)
    find(:first,"session_id = ?",session_id)
  end

  private
  def ensure_user_is_set
    warden_data = self.data["warden.user.user.key"]
    if warden_data
      user_id   = warden_data[1][0]
      self.user = User.find(user_id)
    end
  end
end

I opened 2 browsers ( a Firefox and a Chrome ). The very strange thing is that if I start
a rails console, and I write: Session.count, I get back 1.

Afterwards, I login in Firefox, and then I refresh Chrome. Now both browsers appear as logged in. What am I doing wrong? Why doesn’t each browser have it’s own session?

EDIT: It seems that my custom Session class is causing the problems. However, I’m not sure why.

EDIT 2: The problem was here:

  def self.find_by_session_id(session_id)
    find(:first,"session_id = ?",session_id)
  end

and it should have been:

  def self.find_by_session_id(session_id)
    find(:first,:conditions => ["session_id = ?",session_id])
  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-09T22:59:44+00:00Added an answer on June 9, 2026 at 10:59 pm

    The problem was here:

      def self.find_by_session_id(session_id)
        find(:first,"session_id = ?",session_id)
      end
    

    and it should have been:

      def self.find_by_session_id(session_id)
        find(:first,:conditions => ["session_id = ?",session_id])
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried the obvious SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, but my
I have tried to set up a login page, but when I try to
I have my own site that store login info only in session. I need
I tried to set the tick style to tsManual, the min and max position
I tried to set the background color of a data grid view to be
I tried to set the usergent using Inet1.Execute , GET, Referer: yahoo.com & vbCrLf
I tried to set up the date_select in my HAML template for displaying just
I tried to set up my togglebutton properties layout using style.xml. Here's my code:
I've tried to set up a Django model with a python property, like so:
I've tried to set the margin and border to 0,but still not working. <style

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.