http://clearcove.ca/wp-content/themes/press

29 Sep 2009, Posted by Jo Hund in Ruby/Rails, 1 Comments

Recipe: Detect whether cookies are enabled in rails


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...

30 Mar 2009, Posted by Jo Hund in Note to self, Ruby/Rails, 0 Comments

Simplest way to use cron with Rails


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...

14 Dec 2008, Posted by Jo Hund in Ruby/Rails, 8 Comments

Recipe: RESTful search for Rails


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...

31 Aug 2008, Posted by Jo Hund in Ruby/Rails, 7 Comments

Recipe: Make request environment available to models in Rails


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...

24 Aug 2008, Posted by Jo Hund in Ruby/Rails, 7 Comments

Recipe: RESTful permissions for Rails


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...

10 Aug 2008, Posted by Jo Hund in Ruby/Rails, Tools, 0 Comments

OpenSource project: Quentin Time Tracker


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

Quentin dashboard

(more…)

Continue Reading...

13 May 2008, Posted by Jo Hund in Note to self, Ruby/Rails, 0 Comments

Require Ruby ‘Forwardable’ on Leopard


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...

07 Jan 2008, Posted by Jo Hund in Ruby/Rails, 0 Comments

Litespeed: The best kept Rails deployment secret


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...