chand syed
2011-Oct-11 06:35 UTC
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......... -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Oct-11 08:57 UTC
Re: how to do sum of two columns and store in another column in database
On 11 October 2011 07:35, chand syed <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.