[–] a_w 1y ago ↗ I do this often:```rubyif (user = User.find_by(email: 'abc@example.com')) user.update(status: 'active') end```Is it better to do this instead?```rubyuser = User.find_by(email: 'abc@example.com')user.update(status: 'active') if user.present?```
1 comment
[ 2.1 ms ] story [ 14.3 ms ] thread```ruby
if (user = User.find_by(email: 'abc@example.com'))
end```
Is it better to do this instead?
```ruby
user = User.find_by(email: 'abc@example.com')
user.update(status: 'active') if user.present?
```