Wrap params.require(:resource) in function