converting sg2 to rails