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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:17:52+00:00 2026-05-29T17:17:52+00:00

I haven’t found a good answer to this yet. How can I get my

  • 0

I haven’t found a good answer to this yet. How can I get my Rails app and Sinatra app (mounted in my Rails app’s config.ru) to share a session successfully? If I visit my Sinatra app first, then the Rails app, I get an error like undefined method sweep for {}:Hash, presumably because Rails uses a custom subclass of Hash for storing session info, and Rack::Session::Cookie doesn’t. My code so far:

config.ru

map "/" do
  run MyRailsApp::Application
end

map "/sinatra" do
  use Rack::Session::Cookie, 
      key: "_app_session",
      secret: "<SECRET_KEY>"

  run MySinatraApp
end

config/initializers/session_store.rb

MyRailsApp::Application.config.session_store :cookie_store, key: '_app_session'

config/initializers/secret_token.rb

MyRailsApp::Application.config.secret_token = "<SECRET_KEY>" # same as config.ru

Anything I’ve missed?

  • 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-29T17:17:53+00:00Added an answer on May 29, 2026 at 5:17 pm

    A quick grep of the Rails source reveals sweep is a method on ActionDispatch::Flash::FlashHash, which Rails stores in the session under the flash key.

    Sinatra-Flash also uses the flash key of the session, but it stores a plain Hash object there.

    Rails is getting the object at session['flash'], which is the Hash put there by Sinatra, assuming it is a FlashHash and trying to call sweep on it, hence the error message: undefined method sweep for {}:Hash.

    A possible work around might be to use a different key in the Sinatra app for the flash rather than the default (e.g. flash(:my_flash)[:error]="foo").

    That won’t help if you want to use the flash to see messages when going between Rails and Sinatra though.

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

Sidebar

Related Questions

I haven't found a clear answer to this, so can someone help me? If
Actually haven't found the answer for this one. What for and why do i
Haven't seen many Geneva related questions yet, I have posted this question in the
I haven't seen this question anywhere else, I hope someone can help. I have
I haven't found any documentation on this or seen this done before, but is
Haven't found this in my search on Stackoverflow - I know I've seen a
I haven't found a way yet to customize what items are shown in the
I haven't found any information on MSDN regarding this problem. If we create an
I haven't found a question on this topic so I'll ask. I've never actually
I haven't found anything about it on the web, does mono support ASP.NET 1.1

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.