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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:23:35+00:00 2026-06-03T04:23:35+00:00

I have a model Users and am working with a Session. Users, without being

  • 0

I have a model “Users” and am working with a Session.

Users, without being logged in, are allowed to modify a User.new object in the session, without actually saving the User.

I would like to enable the not-yet-logged-in user to view their Users#Show page.

What is the best way to do this?

Thanks!

  • 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-03T04:23:36+00:00Added an answer on June 3, 2026 at 4:23 am

    In your controller, you could do something like this:

    def show
      @user = current_user || session[:current_user]
    end
    

    So you get the current_user if there is one, and if not, you read from the session.

    Storing an entire model in the session usually sucks though. If you change the underlying class, then the object in the session won’t be unmarshalled correctly, so ensure you reset your session with reset_session after you make changes to your User class or else you’ll get lots of strange errors.

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

Sidebar

Related Questions

I'm working with Rails 3.2.2. And I have a devise model called user. In
I have these models: class UserProfile(models.Model): user = models.OneToOneField(User) #etc class Organization(models.Model): users =
For instance, let's say I have a User model. Users have things like logins,
User is a model. I have 100 users. I need to present the list
I have a working HABTM association between the models Posts and Users... the posts_users
I have a model called company that has_many users then users belongs_to company. class
I have an Organization model that has_many users through affiliations. And, in the form
I have two model: User, Article A user can like or dislike many articles,
I have a model User . The model currently works with a Register view
Back-end: I have a model (User) that has_many of another model (ContactPreference). Front-end: An

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.