Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Aug 15, 2024
1 parent 6ffbe5f commit 57e10af
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,26 @@ class NullPlan
def pro? = false
def ent? = false
end
```

```ruby
class Account
belongs_to :plan, optional: true, null_object: NullPlan.instance
end
```

```ruby
account = Account.create

puts account.plan
# => #<NullPlan>

account.update(plan: Plan.create)

puts account.plan
# => #<Plan id=1>
```

## Supported Rubies

**`null_association` supports Ruby 3.1 and above.** We encourage you to upgrade
Expand Down

0 comments on commit 57e10af

Please sign in to comment.