working version for rails 3