Make rails-4 branch compatible with rails 3