Forum: Ruby on Rails select specified fields from a record

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.
Sergio L. (Guest)
on 2006-05-09 21:33
ok, here is my question, how can i select only one or two, three.. etc
fields from a sentence, for example, i only want to know the id, name
from de User model

User.find(:first, :condiions => ["id = ?", @id])

how can i specify what fields i want??
Jeremy K. (Guest)
on 2006-05-09 22:37
(Received via mailing list)
On May 9, 2006, at 10:33 AM, sergio luis wrote:
> ok, here is my question, how can i select only one or two, three.. etc
> fields from a sentence, for example, i only want to know the id, name
> from de User model
>
> User.find(:first, :condiions => ["id = ?", @id])
>
> how can i specify what fields i want??

Please refer to the API docs:
   http://api.rubyonrails.com/classes/ActiveRecord/Ba...

Also, be mindful that the forum is mirrored to a mailing list -
"throwaway" questions really gum up the works.

Thanks,
jeremy
This topic is locked and can not be replied to.