Skip to content

Commit a39794d

Browse files
committed
LazyAssociation#object should not reevaluate reflection values
1 parent 17d0e6b commit a39794d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Features:
88

99
Fixes:
1010

11+
- [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated.
1112

1213
Misc:
1314

lib/active_model/serializer/lazy_association.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def reflection_options
1111
end
1212

1313
def object
14-
@object ||= reflection.value(
14+
return @object if defined?(@object)
15+
@object = reflection.value(
1516
association_options.fetch(:parent_serializer),
1617
association_options.fetch(:include_slice)
1718
)

0 commit comments

Comments
 (0)