Here is my situation,

In the database, I have a *stats* table which has:

- points (Integer datatype)
- assists (Integer datatype)
- blocks (Integer datatype)
- turnovers (Integer datatype)

In rails, I have *stat* model

Now If I want to display value from stats table, I can do this

@stats = Stat.find(:all)

It will display all integer value that user entered *(Note: User ONLY*

allowed to enter integer value)

For example, I have these data in stats table

*Points* *assists* *blocks* *turnovers*

1 4 5 1

5 2 5 5

7 3 2 7

Now, I want to average each column and assign it to stat class

@average_stat = Stat.new

stats = Stat.find(:all)

@average_stat.points = stats.sum(‘points’) / stats.count(‘points’)

@average_stat.assists = stats.sum(‘assists’) / stats.count(‘assists’)

@average_stat.assists = stats.sum(‘blocks’) / stats.count(‘blocks’)

@average_stat.assists = stats.sum(‘turnovers’) /

stats.count(‘turnovers’)

The problem I see, when I assigning to average value to @average_stat,

the

value get converted to integer. I want to have float value. How I can

assign

float value in stat class?

Yudi S.