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

The Archive Base Latest Questions

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

I have a Rails application, that includes chat. Everything works fine, but now I

  • 0

I have a Rails application, that includes chat. Everything works fine, but now I want to store the last 50 chat messages somewhere. I need it to show the last messages if a page is reloaded. I don’t want to use database. It would be good to store it in some kind of array, but Rails is stateless. I’m looking to make it a little more stateful with your help.

Thx

UPD:

I’ve found PStore ( http://www.ruby-doc.org/stdlib/libdoc/pstore/rdoc/classes/PStore.html ). It looks pretty good for me, doesn’t it?

  • 1 1 Answer
  • 1 View
  • 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-20T00:23:50+00:00Added an answer on May 20, 2026 at 12:23 am
    • Your simplest answer is Marshal, since it is part of the Ruby core. Just dump your actual array to disk as a binary file and read it back as you need.

      MYDB = 'mydb.marshal'
      
      # Write to disk
      last_50 = [ "foo", "bar" ]
      File.open( MYDB, 'wb' ){ |f| f << Marshal.dump( last_50 ) }
      
      # Load from disk
      last_50 = Marshal.load( File.open( MYDB, 'rb' ){ |f| f.read } )
      p last_50
      #=> ["foo", "bar"]
      
    • If you want the file format to be human-readable, try YAML (part of the Ruby standard library) or JSON as a gem. Both are plain-text file formats that you can dump to file, see, and load again.

    • You say you “don’t want a database”, but you don’t say why. Do you know that SQLite has its database in a single file, is easy to install, and is fast and lightweight?

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

Sidebar

Related Questions

I have a Rails application that works with mongodb. I want to deploy it
I have a rails application deployed that works fine in Safari, Firefox, and Opera.
I have a non-rails application that I want to use rails active-record migrations with.
I have a Rails 3 application with a pretty standard multipart form that includes
In my rails application I have two trees that are identical but mounted in
I have a rails application that about 3 years old, and I'm having a
I have a Rails application that uses ActiveRecordStore for sessions. I need a PHP
I have a Rails application that lists information about local services. My objectives for
I have a rails application that allows searches using longitude and latitude. I have
I have a rails application that has three different types of users and I

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.