porting over Pathination from Sinatra to Rails