Could someone please tell me how to escape the ''division'' arithmetic symbol in a model or controller? I''ve searched around and cannot find a solution. I''ve got the following in my model: def avg_risk t = 0 self.audits.each{|key| t = t + key.control_rating } t = t / self.audits.count #this line doesn''t work... I''ve even tried \/ return t end Any help would be appreciated. -- Posted with http://DevLists.com. Sign up and save your time!
On Tue, Feb 28, 2006 at 10:07:50PM -0000, Joshua Schairbaum wrote:> Could someone please tell me how to escape the ''division'' arithmetic > symbol in a model or controller? I''ve searched around and cannot find a > solution.Well, what do you *want* to have happen? And what *actually* happens? Looks like you''re trying to do arithmetic on those values - are you sure they''re numeric? Perhaps one of them is a string or something?> > I''ve got the following in my model: > > def avg_risk > t = 0 > self.audits.each{|key| t = t + key.control_rating } > t = t / self.audits.count #this line doesn''t work... I''ve even tried \/ > return t > end-jim
On Tuesday, February 28, 2006, at 10:23 PM, Jim Cheetham wrote:> >Well, what do you *want* to have happen? >And what *actually* happens? > >Looks like you''re trying to do arithmetic on those values - are you >sure they''re numeric? Perhaps one of them is a string or something? >I''m sure that they''re both numbers. I cannot remember the exact error number because I''m not at work, but the gist of it was the operation could not be completed. I think I''m going to try to install the arithmetic plugin for Rick Olson...or wait for 1.1, all I''m trying to do is get an average value of an attribute for a collection. -- Posted with http://DevLists.com. Sign up and save your time!