Forum: Ruby on Rails Not able to put into a object variable

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
48e2f53bc3396f2633673907dd0d62ad?d=identicon&s=25 Naroor Rathish (naroor)
on 2005-12-16 06:52
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 Rathish,
www.naroor.blogspot.com
5a3762de21f1638e6ab4f61327ba9f33?d=identicon&s=25 Blake Watters (Guest)
on 2005-12-16 07:00
(Received via mailing list)
: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
48e2f53bc3396f2633673907dd0d62ad?d=identicon&s=25 Naroor Rathish (naroor)
on 2005-12-16 07:22
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 Rathish


Blake Watters 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
This topic is locked and can not be replied to.