Flash/Flex Remoting and Disabling Rails Sessions

The things that make web development with Ruby on Rails so easy, and dare I say fun, can also sometimes get in the way or cause unexpected problems (not fun). Rails sessions are generated automatically which is cool if you need sessions for say a shopping cart app. However if you don’t need sessions, or you want to handle data tracking in a different way with Flex/Flash’s Shared Objects, Rails will still chug along and output a session unless you tell it not to.

Here’s how to stop the session madness. Open up the WebORB controller and add this line ‘session :disabled => true‘.

class WeborbController < ApplicationController

  session :disabled => true

This is not Remoting specific and works for any controller in a Rails app. Rails sessions will keep multiplying like those furry things from that infamous Star Trek episode (Tribbles, thanks Google). eventually you’ll need a CRON job on your server to delete sessions from the tmp/sessions folder (or the database if you’re using ActiveRecord Store), so you might as well not create them in the first place and avoid a mess to clean up!

Here’s a good article on Rails sessions.

Post a Comment

Your email is never shared. Required fields are marked *

*
*

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word