Updated for rails 4