Not able to put into a object variable


#1

hello friends ,

I was trying to select all the invoice items from the table invoiceitems
with a condition.But I am getting a NULL array .Please help me in fixing
this ::

@oldinvoiceitems = Invoiceitems.find(:all, :conditions => 

[‘invoice_id = :invoiceid’, { :invoiceid => ‘params[:id]’ } ] )

Thanx and regards,
Naroor R.,


#2

:invoiceid => ‘params[:id]’ should be :invoiceid => params[:id]

Single quoting it passes the invoiveid in as a string literal and not
the value from the request.

Blake


#3

Thanx Blake ,
Also Have a another doubt .Is this possible ::

def new

@invoiceitems = Invoiceitems.new
@oldinvoiceitems = Invoiceitems.find(:all, :conditions 

=>[‘invoice_id = :invoiceid’, { :invoiceid => params[:id] } ]

end

his is for initialising a new invoiceItems object and also finding and
storing all the invoice items for a particular invoice id .I will be
having a page ‘new’ where all the previous invoice items can be stored
and new can be added .

Thanking you,
Naroor R.

Blake W. wrote:

:invoiceid => ‘params[:id]’ should be :invoiceid => params[:id]

Single quoting it passes the invoiveid in as a string literal and not
the value from the request.

Blake