API parameter validation and error handling for Rails