Fix Rails4 related issues