How can I maintain a session across Ruby on Rails pages in an embedded app?

Topic summary

Issue: A Rails 7 embedded Shopify app (shopify_app v22, Ruby 3.2) maintains session on the root posts#index but prompts for Shopify login when navigating to other scaffolded routes (e.g., /posts/new, /posts/1) within the same controller, despite including ShopifyApp::EmbeddedApp and ShopifyApp::EnsureInstalled.

Context: Developer generated a standard MVC scaffold (Post) and set root to posts#index. A screenshot shows a Shopify UI login prompt appearing on non-root routes.

Community input:

  • Another developer reports the same problem.
  • Suggested workaround: pass all Shopify request parameters along to the target routes when navigating. This is described as simple but inelegant.

Key points:

  • The core problem appears to be session/context not persisting across nested routes in the embedded app.
  • No detailed explanation of which parameters to pass or how (e.g., query params vs. headers) is provided.

Status: No confirmed fix or consensus. One workaround offered; the thread remains open with unresolved session persistence across pages.

Summarized with AI on December 12. AI used: gpt-5.

Hello I have successfully create a ruby on rails app based on instructions https://github.com/Shopify/shopify_app

Rails v7, shopify_app v22, Ruby 3.2

For my app I generate an MVC with db tables to save some data

rails generate scaffold post title:string body:text

Then I set the root to the root :to => ‘posts#index’ which works fine and I see the index page from the posts_controller.rb (include ShopifyApp::EmbeddedApp include ShopifyApp::EnsureInstalled added like in Home controller to maintain Shopify session)

However when I go to /posts/new or posts/1 to create new or show existing I see Shopify UI with prompt to login
It seems to me the Shopify gem session is not maintained across the rails pages

What am I missing? How to hold embedded app session through ruby on rails pages (same controller)

As expected no support here

Hello. Anyone here to help? :grin:

I’m struggling with this exact issue myself. :confused:

Hi,

You simply need to pass all the request parameters from Shopify to the route you want to navigate. This approach may not be the most elegant, but it’s a simple and effective solution I’ve found to work in this situation.