port to rails3