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
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
>
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
3 matches
Mail list logo