Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional relationships #2259

Open
wants to merge 2 commits into
base: 0-10-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ tags
Icon?
ehthumbs.db
Thumbs.db

# sdk
.idea
1 change: 1 addition & 0 deletions lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def associations(include_directive = ActiveModelSerializers.default_include_dire
Enumerator.new do |y|
self.class._reflections.each do |key, reflection|
next if reflection.excluded?(self)
next if reflection.options[:optional] && ( instance_options[:included].nil? || !instance_options[:included].include?(key.to_s) )
next unless include_directive.key?(key)

association = reflection.build_association(self, instance_options, include_slice)
Expand Down