以ä¸ã®ãããªå¦çãããããname ã¨ããååã®ã¦ã¼ã¶ãæ¢ãããã®å¹´é½¢ãåºåããã def age(name) Persion.where(:name => name).age end ä¸ã®ã³ã¼ãã¯ã¾ããã¨ãããä¸ç®æããã name ã¨ããã¦ã¼ã¶ãããªãã£ãå ´åã«ãä¾å¤ã«ãªãã¨ããç¹ã ã def age(name) Persion.where(:name => name).age # => NilClass#age is not defined end ãããåé¿ããããã«ã¯ãnilãã§ãã¯ãå ¥ããå¿ è¦ãããããã name ã¨ããã¦ã¼ã¶ãããªãã£ãããnilãè¿ããã¨ã«ããã def age(name) person = Persion.where(:name => name) person ? person.age : nil end åã«å¹´é½¢ãåå¾ãããã ããªã®ã«ãä¸éå¤æ° per
{{#tags}}- {{label}}
{{/tags}}