Re: [Rails] Math with table rows

2011-08-18 Thread Chirag Singhal
You should be doing this in the model, not controller. If you want to do this everytime the user record is saved, then define a before_save callback in your model and add this in the method def udpate_result self.result = self.height*self.weight end Note: You will have to convert height and wei

Re: [Rails] Math with table rows

2011-08-18 Thread Hassan Schroeder
2011/8/18 Cássio Godinho : > In a form I input height and weight values and want to multiply those two > values and store on the resulta row on database. I was trying something like > that >       def criar >         @user = User.new(params[:user]) >         @result = @user.height * @user.weight >

[Rails] Math with table rows

2011-08-18 Thread Cássio Godinho
Lets supose I have a User table, and on this table I have height, weight and result rows. In a form I input height and weight values and want to multiply those two values and store on the resulta row on database. I was trying something like that def criar @user = User.new(params[:use