Move prawn generation code out of controller