-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid saving embedded options in session: Session exceeding size #335
Comments
FWIW, I've been getting around this for years with the following method used as a before_filter on my views/actions that render one or more inline scaffolds. It has its downsides, e.g., some situations where active_scaffold is supposed to save your search and sort preferences, they end up getting lost when you surf to another view, but its better than the entire application blowing up. before_filter :purge_as_session_variables
def purge_as_session_variables
self.session.to_hash.each do |k, v|
if k.to_s =~ /\Aas:/
logger.debug("deleting rails session key: #{k}")
session.delete(k)
end
end
end I've raised this issue in the past, many years ago. I thought I saw a commit a while ago that tried to address this, but I guess not. A better solution would be nice. |
Some session uses have been removed (nested scaffolds), and some are optional (like pagination and search). But embedded scaffolds still use session. It's a pending change |
hey @scambra, just wondering if there has been any other thought given to this issue. I find that the cookie overflow occurs when I want to mark all records in a table with a lot of records. I'm guessing all of those ids are ending up in the session. Is there any way around this? |
Usage of session in mark action could be replaced with usage of local storage or session storage in JS, probably local storage as session storage is independent on different tabs, so it wouldn't be equivalent, or have a config option for it. However, when a custom action need access to marked records, it would have to send the marked records with JS, so custom actions using marked_records method, or each_marked_record, would be broken, unless AS sends marked_records on every xhr request. Or mark action could have a way to define how to save marked records, e.g. in DB instead of session, using a model which saves the marked records with polymorphic association, and saving current user too. Probably, none of those are easy changes. |
We're using AS on our Rails app for a pretty large admin backend. If our admins do enough stuff on certain pages then they get a cookie overflow.
I might know what's going on: those pages are using
render :active_scaffold, constraints: {...}
. The constraints are persisted in the session, and enough constraints are being added throughout their browsing session that it gets too big.This seems to be a fundamental issue with how constraints are passed. I don't understand why they couldn't be passed once to the rendering of an AS component? That would solve the issue that I think this session approach was trying to solve (having pages work even if you visit them through back/forward buttons).
Or if there's something I'm misunderstanding please tell me.
The text was updated successfully, but these errors were encountered: