Action view mutiplication problem and why doesn't method work

Arggh sorry abouht the above post i accidently sent it without
finihing it.

my second question is that i have put this method in the controller

def qx(product,price)
result = product.price * product.quantity

and what i get is “undefined method `qx’ for #<ActionView::Base:

I am putting it in the right place??? i have tried the model but no

I hope ur trying to do

in ur controller

def view
@product = Product.find(params[:id])
@total = qx(@product.price,@product.quantity)

def qx(price,quantity)
return price*quantity


On Sep 1, 8:48 am, tyliong [email protected] wrote:


I am putting it in the right place??? i have tried the model but no

No you’re not. If you want to call the method in the view you need to
put it in a view helper (rails will have created an empty view helper
for you.

Just having it inline in the view file should work though (assuming
what you’ve got are actually all numbers, not strings or something
like that). At the end of the day I’d probably have this as a method
on product.


One more question for methods

in my method i have this:

def qx(food)

in the view i do this

<%= qx(food) %>

but i keep getting “wrong number of arguments (0 for 1)”

i try to do this in view food=“food” and food=food but no luck

btw do all methods without “self.” need to be in the helper file?

and why can’t i multiply 2 ruby records together in the view?
On Sep 1, 4:10 pm, Frederick C. [email protected]