[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

active record quetion.

Junkone

11/25/2007 4:25:00 PM

here is my issue. i want to get the id of of the record extracted
here. it however gives me 37832400
instead of 9. i am not sure why.

>> t=Trade.find_by_sql("select * from trades where tradestatus='O' and symbol_al
ias='USD.CHF-IDEALPRO-CASH'")
=> [#<Trade:0x4828a80 @attributes={"tradestatus"=>"O",
"tradestrategy"=>nil, "sy
mbol_alias"=>"USD.CHF-IDEALPRO-CASH", "tradeinterval"=>"5MINUTE",
"getpictures"=
>nil, "tradename"=>nil, "id"=>"9", "grossrevenue"=>nil, "tradecomments"=>nil, "t
radedirection"=>"Long"}>]
>> t.id
(irb):8: warning: Object#id will be deprecated; use Object#object_id
=> 37832400
>>


2 Answers

Rich Vázquez

11/25/2007 5:46:00 PM

0

t is an Array (see this by typing t.class)
So, t.id is going to return a value related to the Array class as opposed t=
o
the contents.

t[0].id t[1].id etc would return what you are expecting

On Nov 25, 2007 10:29 AM, Junkone <junkone1@gmail.com> wrote:

> here is my issue. i want to get the id of of the record extracted
> here. it however gives me 37832400
> instead of 9. i am not sure why.
>
> >> t=3DTrade.find_by_sql("select * from trades where tradestatus=3D'O' an=
d
> symbol_al
> ias=3D'USD.CHF-IDEALPRO-CASH'")
> =3D> [#<Trade:0x4828a80 @attributes=3D{"tradestatus"=3D>"O",
> "tradestrategy"=3D>nil, "sy
> mbol_alias"=3D>"USD.CHF-IDEALPRO-CASH", "tradeinterval"=3D>"5MINUTE",
> "getpictures"=3D
> >nil, "tradename"=3D>nil, "id"=3D>"9", "grossrevenue"=3D>nil,
> "tradecomments"=3D>nil, "t
> radedirection"=3D>"Long"}>]
> >> t.id
> (irb):8: warning: Object#id will be deprecated; use Object#object_id
> =3D> 37832400
> >>
>
>
>
>


--=20
--
Rich V=E1zquez, CISSP, CISA

Junkone

11/25/2007 7:02:00 PM

0

On Nov 25, 12:45 pm, Rich Vázquez <rich.vazq...@gmail.com> wrote:
> t is an Array (see this by typing t.class)
> So, t.id is going to return a value related to the Array class as opposed to
> the contents.
>
> t[0].id t[1].id etc would return what you are expecting
>
> On Nov 25, 2007 10:29 AM, Junkone <junko...@gmail.com> wrote:
>
>
>
>
>
> > here is my issue. i want to get the id of of the record extracted
> > here. it however gives me 37832400
> > instead of 9. i am not sure why.
>
> > >> t=Trade.find_by_sql("select * from trades where tradestatus='O' and
> > symbol_al
> > ias='USD.CHF-IDEALPRO-CASH'")
> > => [#<Trade:0x4828a80 @attributes={"tradestatus"=>"O",
> > "tradestrategy"=>nil, "sy
> > mbol_alias"=>"USD.CHF-IDEALPRO-CASH", "tradeinterval"=>"5MINUTE",
> > "getpictures"=
> > >nil, "tradename"=>nil, "id"=>"9", "grossrevenue"=>nil,
> > "tradecomments"=>nil, "t
> > radedirection"=>"Long"}>]
> > >> t.id
> > (irb):8: warning: Object#id will be deprecated; use Object#object_id
> > => 37832400
>
> --
> --
> Rich Vázquez, CISSP, CISA- Hide quoted text -
>
> - Show quoted text -

thanks for the pointer. my bad.