How to do sum of two columns and store in another column in database

Hai friends…

My question is I have one table in that three columns a, b and c…

a=7 and b=10 given input now c value must be store as a+b means 7+10=17.

Please can anybody tell me solution…

Tahnk you…

On 11 October 2011 07:35, chand syed [email protected] wrote:

Hai friends…

My question is I have one table in that three columns a, b and c…

a=7 and b=10 given input now c value must be store as a+b means 7+10=17.

Don’t do it, there is no need as you can work it out whenever you need
it. So do not have a column c in the database, just provide method c
in the model:
def c
a+b
end

Then you can use your_object.c just as if it were a column in the db.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs