Port to rails3