try to make compatible with rails 4.x+