Jamis Buck and I had a few ideas tonight that would each take care of the CgiRequest bug where switching between Rails apps that have different classes (models) stored in the session causes the whole app to crash without a trace.  Of course, the problem is only present when using the FileStore to store session data, since if the sessions are being stored in the DB, there shouldn't be any conflict between apps.

Option #1: Add a "tmp" folder to the Rails app directory structure and store session files in "#{RAILS_ROOT}/tmp".  If each app has its own tmp folder, we could instruct it do something like this inside of the Rails initializer:

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:tmpdir] = File.join(RAILS_ROOT, 'tmp')

Option #2: Create some kind of UUID or unique ID per app, and store rubysess files in "/tmp/#{app_specific_id}/rubysess.*"  This would require modifying railties to create a UUID when the rails app is first generated.

Option #3 (?): Use the UUID in the rubysess filename, e.g. rubysess.#{app_specific_id}.#{random_number}.  I don't know if this one is possible, since I don't know of a way to change the name of the files that CGI::Session FileStore.


I've heard that some core members aren't too excited about adding a tmp/ folder to RAILS_ROOT, and I can understand why; however, adding the tmp/ folder (option #1) may be the best solution for a number of reasons:

a) It guarantees that there will be no conflict between rails apps
b) Apps can benefit from the change immediately (no need to generate a UUID with railties)
c) We'll finally have a place to put those pesky fastcgi socket files
d) Other plugins may benefit from a tmp/ folder, e.g. file_column?


Cast your ballots.


Duane Johnson
(canadaduane)


_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to