flash[:error] should not be in model class. It is responsibility of controller to set flash messages or call appropriate error views. You could break the 'generate' method down into 'validate' and 'generate' methods. So that controller first calls validate to validate parameters, and gets an error string or array of error strings on error. Then the controller can call generate method if no error (nil) is returned by the validate method.