Fix problems for rails 4