Improve compatibility with rails3