Follow

```ruby
current_use.badges
.where(badges: badge)
.create_with(achieved_on: Time.current)
.create_or_find_by!({})
```
syntax is ridiculous. Including the mandatory `{}`. And it's the only way to create or find a record if it exists with `[:user_id, :badge_id]` unique index on the `user_badges`. The original `find_or_create` that suffers from race conditions is way easier to use.

Sign in to participate in the conversation
Ruby.social

A Mastodon instance for Rubyists & friends