æåã«ã¾ã¨ã
tap 便å©ã ã£ã
ããããã£ããã¨
SomeHistory. # 5ã6è¡ãããã®ãªããè¤é㪠ActiveRecord::Relation ã®ã¡ã½ãããã§ã¼ã³ pluck(:user_id)
ããããã¯ã¨ãªã«å¯¾ãã¦éã«å®è¡è¨ç»ãã¨ãããã£ã
pluck
ãå¼ãã æç¹ã§æ»ãå¤ãArrayã«ãªãã®ã§ pluck(:user_id).explain
ã£ã¦ã®ã¯ã§ããªãã
ãã¨ãã£ã¦explainã®ããã ãã«5ã6è¡ãããããã¡ã½ãããã§ã¼ã³ã³ããããããªãã£ãã®ã§ã©ããã£ããªã¼ã¨æã£ãã tap
ãæãã¤ãã
ããæ¹
pluckãå¼ã¶ç´åã«tapãä»è¾¼ãã§explain
SomeHistory. # 5ã6è¡ãããã®ãªããè¤é㪠ActiveRecord::Relation ã®ã¡ã½ãããã§ã¼ã³ # NOTE: å®è¡è¨ç»ã®çµæãå¤ãããããselectããªãå ´åã¯ã¤ãã¦ãããtap { |ar| puts ar.select(:user_id).explain } ã¨ãã§ãå¯ select(:user_id). tap { |ar| puts ar.explain }. pluck(:user_id)
ä½è«
ã©ãã§ãããã§ãããéï¼ãã¤ï¼ãã¨ãtapï¼ãã£ã·ï¼ãã£ã¦èªæä¼¼ã¦ã¾ãããï¼