Adapt for rails 4