Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Using sessions and caches only on certain actions in Rails

Stolen from Typo and found here. Typo is on an open licence so this should be okay.. :)

class ArticlesController < ApplicationController
  cached_pages = [:index, :read, :permalink, :category, 
    :find_by_date, :archives, :view_page, :tag]
  caches_page *cached_pages
  session :off, :only => cached_pages

  ...
end


Means you'll end up with less pointless sessions being stored..

Automatically erase Ruby on Rails session files

Add to your cron:

1 */4 * * *     find /tmp/ -name "ruby_sess*" -cmin +600 -exec rm \{} \;


Deletes sessions over ten hours old every four hours. Otherwise your /tmp will end up overflowing. This only applies you use the file store method of session storage with Rails.

Delete old Rails sessions

find /tmp/ -name "ruby_sess*" -cmin +60 -exec rm \{} \;
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS