Fix rails 2 comptability

The rails2 compatibility got broke by commit 5d055e0633. This patch fixes it and still works for both rails 2 and 3