Archive | Rails

19 September 2009 ~ 0 Comments

Radiant CMS, disable caching in development

I am working on extension for Radiant CMS. I wanted to disable caching for development, but wasn’t able to find right method for this, so finally I did it by putting this into my extensions activate method if RAILS_ENV==”development” Page.class_eval { def cache? false end } end This is more of a hack then a [...]

Continue Reading

23 November 2007 ~ 1 Comment

Disabeling sessions in Rails

The simplest way to disable sessions in Rails is to use session :off (see ActionController::SessionManagement::ClassMethods). session :off To disable session suport only for a specific controller add session :off to that controller class MyController < ApplicationController session :off end Written like that, sessions are disabled for all actions on this controller. Like filters, you can [...]

Continue Reading

22 August 2007 ~ 0 Comments

Determining the number of days in a month

Here is a simple method that returns number of days for wanted month and year. If year is ommited current year is selected. def month_days(month, year=Date.today.year) mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] mdays[2] = 29 if Date.leap?(year)mdays[month] end Simple examples: month_days(1) => 31 month_days(2, 2007) => [...]

Continue Reading

25 July 2007 ~ 1 Comment

Quick Start with Rails on OS X

Install Ruby OS X (10.4) comes with Ruby 1.8.2 already installed. For a quick start this is OK so let’s install Rails. Install Rails Since Rails comes as gem package, first we need to install RubyGems. Download the latest package from RubyForge and unzip it. Now go to the directory where you unpacked the package [...]

Continue Reading