On 6/7/07, Kesi Asstami
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Hi, I am new to Ruby, I am a Java expert.
> I don''t know how to handle the results of a search... I have read
a lot,
> but nobody seems to give examples of that.
> Do I get an ArrayList from a Table?
> Do I get fields?
> How can I identify them?
> Do I have to parse them to a Class like: Person user >
Person(personlist.get(i));?
>
> Please, help me...
Assuming you are referring to Rails specifically, not just Ruby. As an
aside, get the book Agile Web Development with Rails. (Use the Google).
ActiveRecord''s finders either return an array:
@users = User.find(:all, :conditions => [''name = ?'',
''scott''])
or one object
@user = User.find(1) # gets the user with an ID of one.
to iterate, you can use .each:
@users.each do |user|
puts user.name
end
--
Scott Becker
Electro Interactive, Inc.
Blog: http://synthesis.sbecker.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---