khiav223577 / deep_pluck

Allow you to pluck attributes from nested associations without loading a bunch of records.
MIT License
460 stars 14 forks source link

need serializer support #16

Open kakas opened 6 years ago

kakas commented 6 years ago

可否支援 deep_pluck 出 model 裡面序列化的欄位?

e.g
class User < ActiveRecord::Base
  serialize :preferences, Hash
end

# in controller

User.where(id: 1).deep_pluck(preferences: [:food, :car])
khiav223577 commented 6 years ago

以目前 deep_pluck 的設計

users.deep_pluck(preferences: [:food, :car])

預期的輸出格式會是:

[
  {preferences: [{food: xx, car: xx}, {food: xx, car: xx}, ......]}, # user1
  {preferences: [{food: xx, car: xx}, {food: xx, car: xx}, ......]}, # user2
  ...
  ...
]

跟你想要的不太一樣

可能要再想想語法格式的問題