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...
Yesterday Trevor mentioned the Ack TextMate bundle he developed to provide better “Search in project”. I installed it and was instantly sold:
- search is much faster using ack
- the results list pops up instantly with the first hits, and then it just keeps growing as you start reviewing the results
- it has an option to show context around the results (see screenshot below)
- you can customize the search behavior on a per user or per project basis using a .ackrc file
- it has an option to follow symlinks. Useful for me because I symlink rails into vendor for my apps. Normally I don’t want to include the rails source in my project search
- search is limited to currently selected file/folder and its children. Useful for scoping searches.
(more…)
Continue Reading...
I am learning Smalltalk and will document my progress in a series of blog posts. I have heard too many interesting things about it to ignore it any longer. I am hoping to use it for web development and while learning it, to become a better programmer in other languages as well.
(more…)
Continue Reading...
Kent Beck in his book “Implementation patterns” explains why it makes business sense to write good code:
Businesses that are able to develop and release with confidence, shift direction in response to opportunities and competition, and maintain positive morale through challenges and setbacks will tend to be more successful than businesses with shoddy, buggy code.
Continue Reading...