Rebuilt rails 3 implementation