Skip to content

Commit

Permalink
use _ids method instead of pluck
Browse files Browse the repository at this point in the history
  • Loading branch information
nragaz committed Dec 21, 2012
1 parent a74fc6c commit be005c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/active_model/serializer/associations.rb
Expand Up @@ -109,8 +109,10 @@ def serializables
def serialize_ids
# Use pluck or select_columns if available
# return collection.ids if collection.respond_to?(:ids)
if !option(:include) && associated_object.respond_to?(:pluck)
associated_object.pluck(:id)
ids_key = "#{key.to_s.singularize}_ids"

if !option(:include) && source_serializer.object.respond_to?(ids_key)
source_serializer.object.send(ids_key)
else
associated_object.map do |item|
item.read_attribute_for_serialization(:id)
Expand Down

0 comments on commit be005c6

Please sign in to comment.