How to update my satisfaction and no.of reviews coloumn in my table 1 coloumn

I am totally newbie in the rails and I have searched for my problem to
solve it then I found an example from
Comming to my problem I have two databases they are

one looks like as follows “Names” table name place satisfactionscore no.ofratings rank
1 raj usa
2 ravi usa

And I user_ratings table looks like

id user_id names_id R1 R2 R3 R4 R5
1 1 1 2 3 4
2 2 1 4 5
3 3 2 2 3 3 3 3

Now I am trying to find the satisfaction score immediately after
the values. and no.of ratings My formula is for finding is satisfaction
score is

attribute score[ (sum(r1)/no.of rating for r1) + (sum(r2)/no.of rating
for r2)+(sum(r3)/no.of rating for r3)+…+(sum(r5)/no.of rating for r5)]

Where the total no.of ratings is (sum(no.of ratings for r1+ r2+
For satisfaction score (attribute score/ ratings)

So how can I find the statisfaction score.

I have kept in my ratings model as

after_create :update_post_average_rating
def update_post_average_rating

and in my names model as

def update_average_rating
update_attributes(:satisfaction => self.ratings.average(:ratings))

Can any one tell me how to do this. I am unable to understand how can
I do it.

On 15 January 2014 01:57, raju [email protected] wrote:

I am totally newbie in the rails

First work right through a good tutorial such as
(which is free to use online). That will show you the basics of
rails. Also look at the Rails Guides.