fixed code for active record 2 backward compatibility