2012å¹´10æ11æ¥17:39 Ruby Rails3.2ããå°å ¥ãããpluckã¡ã½ããã®ããã©ã¼ãã³ã¹ãç´ æ´ããã件 Rails3.2ããæ°ãã«è¿½å ãããæ°æ©è½ã¨ãã¦pluckã¡ã½ããã¨ããã®ããããã§ããã ï¼pluckã¯å¼ãæãã¨ããæå³ã®ããã§ãï¼ ããã大å¤ç´ æ´ããããªã¨æåãã¾ããããããããã®ã¡ã½ããã¯å¼æ°ã¨ãã¦ã«ã©ã åã渡ãã¨ãã®ã«ã©ã ã®å¤ãé åã§è¿ãã¾ãã User.pluck(:name) # => [sasata299, name1, name2, name3, ...] ã¤ã¾ããUser.all.map(&:name)ã¨åããããªå¦çãªã®ã§ãããç´ æ´ãããã®ã¯ãã®ããã©ã¼ãã³ã¹ã§ããmapã使ã£ãå ´åï¼selectã§çµè¾¼ã¿ãããå ´åã¨ãã¦ãªãå ´åï¼ã¨pluckã使ã£ãå ´åã§ããã©ã¼ãã³ã¹ãæ¯è¼ãã¦ã¿ã¾ãããã ããããã®å¦çã1000åãã¤è¡ã£ã¦è¨æ¸¬ãã¦ã¿ã¾ãã
{{#tags}}- {{label}}
{{/tags}}