views:

26

answers:

2

In rails + jQuery I am trying to make a get request back to the server when an option in the dropdown box is changed. I use the following jquery code:

$("#product_prod_name").change(function(){
    $.get("/page/volume_or_quant", "id="+$(this).val(), function(result) {
        alert(result)
    })
})

now this is giving an error: Missing template pages/volume_or_quant.erb in view path app/views

As you can see...i have no need to create a view. I just want some response back from my action. My action looks like below:

def volume_or_quant
    @product = Product.find(params[:id])
    @product.volume     
end

What is the best thing to do here?

A: 
def volume_or_quant
    @product = Product.find(params[:id])
    @product.volume    

    # tell rails to ignore the view
    render :layout => false
end

Should do the trick for you.

Rabbott
This only ignores the layout, but requires a view nevertheless.
vise
+2  A: 
def volume_or_quant
    product = Product.find(params[:id])
    render :text => product.volume      
end
vise