Skip to content

Commit

Permalink
Fix has_one getter for nilable type
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Nov 29, 2020
1 parent b98e233 commit 49a9dbc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/clear/model/modules/relations/has_one_macro.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ module Clear::Model::Relations::HasOneMacro

{% if nilable %}
def {{method_name}}! : {{relation_type}}
if model = self.{{method_name}}.nil?
if model = self.{{method_name}}
model
else
raise Clear::SQL::RecordNotFoundError.new
end

model
end # / *!
{% end %}

Expand Down

0 comments on commit 49a9dbc

Please sign in to comment.