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

About this user

Peter Cooperx http://www.petercooper.co.uk/

« 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.. :)

   1  class ArticlesController < ApplicationController
   2    cached_pages = [:index, :read, :permalink, :category, 
   3      :find_by_date, :archives, :view_page, :tag]
   4    caches_page *cached_pages
   5    session :off, :only => cached_pages
   6  
   7    ...
   8  end


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

Automatically erase Ruby on Rails session files

Add to your cron:

   1  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

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