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 create
@user = User.new(params[:user])
@result = @user.height * @user.weight
@user.result = @result
But its not working, what am i doing wrong?
I think it would be nicer to have the computation done on a before_save filter on the model. Using the first 2 answers, it should look like this:
users_controller.rb
user.rb