~iany/ Menu
  • Series
  • Tags
  1. Home
  2. Tags
  3. Session

Session

A collection of 1 article

How Rails Assets Prefix Disables the Session

This is original posted on intridea blog. I recently worked in a Rails project with Peter (@sporkd). The project is intended to be used as a sub-site, and should be served under sub-URI. After google, we ended up by setting config.assets.prefix and wrapped all routes in scope. The solution is simple and worked well. But soon, some weird bugs were found, and Peter was successfully isolated the problem to session (see demo sporkd/asset_prefix_test) After several hours debugging, I finally found out the cause. To make a long story short, the routes configured in routes.rb should not start with config.assets.prefix, otherwise session save is skipped. The demo sporkd/asset_prefix_test can be fixed by simply setting config.assets.prefix to /one/assets. You also get a bonus by setting a unique prefix for assets, since it is easy to add expiration header for assets in web server.

Updated Nov 19, 2025  •  3 min read

© 2026  •  ~iany/  •  CC-BY-SA 4.0