In general our guidelines are against using ternaries for the simple fact that it takes a little more concentration to grok but I think I'd be ok with this if it was extracted to a small private method with an intention-revealing name, like:

```ruby
# ...
@user.username = valid_username_or_nil
# ...
```

```ruby
private

def valid_username_or_nil
  params[:user][:username] == '' ? nil : params[:user][:username]
end
```

In this case I'd consider this a pattern of writing test, failing, making it pass, then refactoring for legibility, or elegance. The small private methods, when extracted from *somewhat* harder to read snippets of code, can go a long long way.