Sinatra to rails conversion