Fix sizes variable and move Ruby code from view over to controller