Check if rails is defined before loading rake task