I think this would probably be easier to parse:

```ruby
def set_content_view(system, activation_keys)
  key = activation_keys.detect { |key| key.environment && key.content_view }
  if key
    system.environment = key.environment
    system.content_view = key.content_view
  else
    fail _('At least one activation key must have a lifecycle environment and content view assigned to it')
  end
end
```