Fix rails 3 compatibility
Complete rails 3 compatibility