all of the above and this
http://railscasts.com/episodes/14-performing-calculations-on-models On Wed, Sep 22, 2010 at 5:50 AM, Edmond Kachale < [email protected]> wrote: > > 2010/9/22 Abder-Rahman Ali <[email protected]> > > I have a small Rails application I'm creating. >> >> I have for example a field called "sales_result". >> >> I also have another two fields, namely, "price" and "quantity_sold". >> >> I have the following formula: >> >> sales_result = price * quantity_sold >> >> How can I perform this formula in my rails application? Such that, when >> I for example enter the following values: >> >> price = 3.0 >> quantity_sold = 3 >> >> I get this result calculated automatically for "sales_result": >> >> sales_result = 9 >> >> Where should I start in the Rails application in performing this >> calculation? >> > > The Rails' Way of doing things is to have fat models and thin views. In > other ways, most of the code that deals with critical operations like > calculations, database manipulations need to be done at a "model" level. > Remember that Rails is a Ruby framework, where as Ruby is object oriented. > And by being an object-oriented programming language, most of the operations > happen within the object itself. > > If you want to get the calculations automatically, consider using AJAX. > > --- > Edmond > Software Developer | Baobab Health Trust (http://www.baobabhealth.org/) | > Malawi > > Cell: +265 999 465 137 | +265 881 234 717 > > *"Many people doubt open source software and probably don’t realize that > there is an alternative… which is just as good.." -- Kevin Scannell* > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

