Sum fields and display running totals in /new

Being new to rails and ruby I’m a bit lost.

Have a data entry scaffold, Details, which has name, string,
cost1:integer cost2:integer cost3: Total:integer
The user inputs puts a value into each of 3 fields.

The totals field should ideally be automatically updated as each value
is entered or changed. Then Save stores all 4 values into the database.
One of the values cost3 should display a tax value of 10% of that
particular entry beside the entry.

Is this possible to do this or should I have something like a cart and
display the calculations in that?

I have read the Agile Web D. books, Enterprise Recipes,
Advanced Rails, Why’s Poignant, Head First Rails which is for rails2 so
some scripts fail.
None explain how to do some of the more simple things like the above or
taking a value from a select list and using it to update a field in
another view.
I’ve been searching for days with no luck,
Thank you in advance
R

On 31 January 2013 10:42, Roger McDonald [email protected] wrote:

Is this possible to do this or should I have something like a cart and
display the calculations in that?

First don’t store the total in the database, provide a method of the
model called total which works it out when you need it. If you store
it then you add all sorts of complications making sure you keep the
total correct when you change the other fields, and there is no need
to add the complexity.

Second, if you want the total and tax value displayed on screen as
they are entered then that must be done by javascript so that is not a
RoR issue. Some tutorials on javascript and probably jQuery are in
order.

I have read the Agile Web D. books, Enterprise Recipes,
Advanced Rails, Why’s Poignant, Head First Rails which is for rails2 so
some scripts fail.
None explain how to do some of the more simple things like the above or
taking a value from a select list and using it to update a field in
another view.

I don’t understand what you mean by the last sentence.

If you have not been able to work right through a tutorial so far then
I suggest railstutorial.org which is free to use online. There is
nothing like actually working through a tutorial, doing the exercises
and so on, to get a grasp of the basics.

Colin