#897: chose right way depending on the rails version not breaking the rails 3 compatibility