On 22 September 2010 10:27, Abder-Rahman Ali <[email protected]> wrote: > 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?
You can define a method sales_result on the appropriate model which returns the required value. Colin -- 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.

