well, you''re going to get a bunch of Client objects using find,
however, you should only get the attributes you specify in the :select
option, instead of all the attributes.
>> User.find(:all, :select => ''login'')
=> [#<User:0xb771061c
@attributes={"login"=>"foo"}>, #<User:0xb77105e0
@attributes={"login"=>"goo"}>, #<User:0xb77105a4
@attributes={"login"=>"bar"}>, #<User:0xb7710568
@attributes={"login"=>"baz"}>]
>> User.find(:all, :select => ''login'').collect { |u|
u.login }
=> ["foo", "goo", "bar", "baz"]
another option is to drop down into the connection and run your query,
if you want to skip the above, but you''ll have to write out your sql.
>> ActiveRecord::Base.connection.select_value("select login from
users")
=> ["foo", "goo", "bar", "baz"]
On 2/21/07, Helder Oliveira
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> @c = Client.find( :all,
> :select => ''denominacao'',
> :include => :works,
> :conditions => ''works.estado = 1'')
>
> im trying to get only one field "denominacao" but i get them all,
is
> there a way to get only one, using activerecord ofc...
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---