# Re: ruby on rails book, fundamental question

**URL:** <https://www.ruby-forum.com/t/re-ruby-on-rails-book-fundamental-question/93978>\
**Category:** Rails\
**Created:** [April 17, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/re-ruby-on-rails-book-fundamental-question/93978 "2006-04-17T15:04:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ianroddis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@ianroddis](https://www.ruby-forum.com/u/ianroddis)\
**Post date:** [April 17, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/re-ruby-on-rails-book-fundamental-question/93978/1 "2006-04-17T15:04:50Z")

</div>

If you write out the loop in long hand it makes more sense.

for each item in products array

item dot title =

next item

If you know the id in particular you want to show you can do  
item[1].title  
otherwise you have to loop through them.

--------- Original Message --------  
From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Rails] ruby on rails book, fundamental question  
Date: 17/04/06 17:58

> I will try to explain this.&nbsp; If you do the same command from  
> ./script/console "@products = Product.find(:all)", you will be  
> able to access this hash by calling each element as @products[1].title  
> or by  
> other keys in the hash.&nbsp; Does that make since?  
> JohnOn 4/17/06, Jan \<removed\_email\_address@domain.invalid\> wrote:  
> Hi guys,bought the ROR book. I understand most of it and really like it.  
> Thereis just on thing I just dont get.Lets take this code for  
> example.def  
> list&nbsp;&nbsp; @products = paginate :product, :per\_page =\> 10  
> endAs far as I understand @products should be some kinda hash or  
> array,with the data of the Database inside.How can I display this array  
> ?One  
> solution is to do it like this (like in the book)  
> \<% for product in @products  
> -%\>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<img  
> src="\<%= product.image\_url %\>"/\>\<% end %\>But I  
> want  
> to understand (!) how this works. Something like  
> puts@products["title"] or puts @products[:title] which  
> obviously  
> doesnt  
> work.I think this would help to understand the whole concept.Thanks  
> alot–Posted via  
> [http://www.ruby-forum.com/.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_](http://www.ruby-forum.com/. _______________________________________________ )  
> Rails mailing  
> removed\_email\_address@domain.invalid://lists.rubyonrails.org/mailman/listinfo/rails
