Closed
Description
Expected behavior vs actual behavior
Given the following serializer:
class PostSerializer < ActiveModel::Serializer
has_many :comments do
link :related do
href "/posts/#{object.id}/comments"
end
include_data false
end
end
This correctly does not include comment relationship data in the response. However, all the comments are still loaded (ie select * from comments where post_id = ?
). I would expect this to avoid loading the comments since none of that data is needed in the response.
Steps to reproduce
Any serializer with include_data false
, look at the ActiveRecord queries that fire.
Environment
ActiveModelSerializers Version (commit ref if not on tag): master/0165215
Output of ruby -e "puts RUBY_DESCRIPTION"
: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
OS Type & Version: OSX 10.10.5 (Yosemite)
Integrated application and version (e.g., Rails, Grape, etc): Rails 5 beta 3