If your Rails app requires cookies, this recipe is for you: It detects whether cookies are enabled, and if not, shows a message to your users.
(more…)
Continue Reading...
For simple applications I use cron to run automated background jobs like sending emails or indexing sphinx.
I like to have all aspects of my application under version control. Cron is no exception. To do this, I add a file named “crontab” in /config. In there I add all my cron jobs in regular cron notation.
(more…)
Continue Reading...
This recipe shows you how to search, filter, and sort your resource lists in a restful way. We will look at the most simple way to accomplish this and then provide some pointers to further improvements. This recipe works great with will_paginate. It is an end to end solution (model, view, and controller). This recipe requires Rails 2.2.2 or greater if you want to use :joins in named scopes. Otherwise Rails 2.0 is sufficient.
(more…)
Continue Reading...
How often do you wish you had access to current_user in one of your models? I needed it for an app that required auditing. I had ActiveRecord call backs on the audited models to create audit entries on every record operation. The problem was that the models had no access to the currently logged in user. (more…)
Continue Reading...
A common requirement for Rails applications is to check permissions for certain actions on your RESTful application’s resources. There are many ways to solve this problem, ranging from simple boolean flags to full fledged role based access control. I have tried a lot of approaches and have settled on a fairly simple way that is RESTful and quite flexible.
(more…)
Continue Reading...
Being a contract software developer, tracking my time is extremely important for my business: I need to write invoices with task break downs, I want to get better at estimating, and I am just curious about what I spend my time on.
So I filled this need by writing my own Rails time tracker: meet Quentin. I cleaned it up a bit and just published it as an MIT-licensed open source project on github.

Quentin dashboard
(more…)
Continue Reading...
When I upgraded to Leopard, some of my Rails apps broke. Ruby threw this error at me:
uninitialized constant User::Forwardable
Here is a simple fix:
require 'forwardable'
in environment.rb.
It seems that on Tiger ‘Forwardable’ was included by default, but not on Leopard any more. Not exactly sure why this is.
Continue Reading...
There is a great way to deploy rails applications. I know it is being used on some high traffic production deployments. How come it never gets mentioned in any official Rails documentation?
Litespeed is its name. It is free — not open source though. And that may be the reason why you don’t hear much about it in the Rails community.
(more…)
Continue Reading...