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.
This recipe checks for the presence of a specific cookie (“cookie_test”). If it is present, the request continues normally. If it is not present, then it sets the cookie, redirects to the “cookie_test” action and checks there whether the cookie is present. If the cookie is present, then everything continues on normally. If the cookie is still not present, then this is a strong indication that the user has cookies disabled. Then the recipe shows a page to the user explaining the cookie requirement. I leave it up to you to write the copy for that page.

Flow chart for the cookie detection recipe
This recipe works as of Rails 2.3 (new cookie handling). It is inspired by this article. The recipe in the original article does not work with newer versions of rails. So I updated it and packaged it up in a neat little module that you can include in your application controller.
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.
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.
Here is what you will get from this recipe:
I have used strftime a lot lately on one of my projects. I could not find a user friendly reference for strftime, so I wrote one. Here is my user friendly strftime cheat sheet in PDF format:
In case you are wondering what strftime does: It allows you to represent a date/time as a formatted string. Example:
Time.now.strftime('%A, %l:%M %p')
=> "Friday, 9:06 AM"
And here is some handy Ruby code to look at the options for strftime:
def print_line(char)
puts "%#{char}: #{Time.now.strftime("%#{char}")}"
end
('a'..'z').each do |char|
print_line(char)
print_line(char.upcase)
end
Here is what I had to do to enable tablet pressure support for the X11 based Gimp and Inkscape applications on OS X Leopard:
My setup:
Key points are:
Nice. Now we have pressure support on OS X for these two great apps. The Inkscape calligraphy tool is very nice. Makes my handwriting look nicer than on paper.
it’s been officially released for a few days now and I think it is a big deal. OpenOffice.org 3.0 is a big step forward:

OpenOffice.org 3.0 spreadsheet application
or What they mean with thinking outside of the box.
Reading this article reminded me of a concept that applies to software design, user interface design, hardware engineering, and pretty much to any situation where you have to solve a problem creatively. I have applied it in a number of disciplines, however I have not used it in my current software design work as much as I should.
It is the concept of designing breadth first, before developing an idea further by going deep. Most creative people I have met (including myself) have the natural tendency to go deep first. They are confronted with a problem, they immediately come up with an idea for how to solve it, they get to work developing that idea, and get stuck in one limited way of thinking.
More …
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 …
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.
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