"Sum/Avg method in Rails , save a query"

Ever wondered about the Calculations in Rails, I used to use the group_by in SQL or select to do many calculations while fetching the results , but sometimes Rails doesnt allow to use group etc , like when we are doing AJAX calls in v2.1.0 of rails .


Then Joejeet helped me to get the following calculations methods , it was so beautiful that my 3 line of code was convered to 1 single line.


Code
@rating_sum = Rating.sum(’rating’, :conditions =>[“rateable_id = ? and rateable_type = ?”, @rating.rateable_id, @rating.rateable_type])


There are other methods like Avg,minimum, max,count etc available under
Module: ActiveRecord::Calculations::ClassMethods


calculations, calculations in rails, sum, avg, minimum, rails

Advertisements
"Sum/Avg method in Rails , save a query"

"OBC bank – Locker was damaged as external metal strip was badly twisted ."

Account no 4968
With Sector 19 , Chandigarh branch .


 

TO whomsoever it may be concerned .




I am having a very old account with the above mentioned branch.


Due to the trust with the branch I had also opened a branch for the past 3-4 years .




Today (13 of April ,2009) I went to operate my locker in the same branch .


I was shocked to find that someone had tried to break the locker and had harmed the external metal socket for an additional lock.


The external frame where we can put out own lock , was twisted and was a clear indication that


someone had tried to break the locker .


This is a clear sign of negligence on the part of the branch .




I have submitted a written note to the assistant manger of sector 19, Chandigarh and had personally shown him the locker .




I request/demand immediate action and clarification in written as to what had happened and who is to blame.




Also I need a immediate replacement of the locker .




This sort of negligence destroys my long trust with the branch even though nothing was missing from the locker yet whatever had happened was not right .




I don’t have much to say , as I feel very disturbed by what had happened or was tried .


Looking forward.




"OBC bank – Locker was damaged as external metal strip was badly twisted ."