baker1 wrote:
> if i have a table called cars with columns called year
and type, and i
> create a model and do this
>
> mycars = Cars.find(:all)
>
> in my view i have something like this
>
> for cars in mycars
> do something like print out cars.type
>
> i know that mycars in a hash where each key is a
column name paired
> with its corresponding value right?
mycars will be an array of Car objects, each
containing an attribute
hash with column name keys.
> without the for loop, how can i access the 2nd record
directly?
> mycars[0].type = ?
mycars[1].type = ?, though you probably will not know
what car
this is unless you use an :order option in your find that is
some sort of consecutive sequence number.
--
We develop, watch us RoR, in numbers too big to ignore.
_______________________________________________
Rails mailing list
Rails lists.rubyonrails.org
h
ttp://lists.rubyonrails.org/mailman/listinfo/rails
|