LoginSignup
0
0

More than 3 years have passed since last update.

rails 発展その9 数学処理

Posted at

averageメソッド

平均を出すメソッド

  golf.average(:score)
  #=> 小数点まで含んだ平均点

roundメソッド

四捨五入するメソッド

   10.4.round
  #=> 10

countメソッド

数えるメソッド

   ninety.group(:product_id).count
   #=> {91=>2, 92=>1, 93=>4}
   #groupメソッドで指定したカラムの値です。
   #この例ではproduct_idになります。ハッシュの値はgroupメソッドでまとめられたレコード数です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0