I''m looking through the api for something like find(:all, :distinct => true) so that multiple instances of a row won''t be returned - is this possible? Thanks!
Daniel Higginbotham wrote:> I''m looking through the api for something like find(:all, :distinct => true) > so that multiple instances of a row won''t be returned - is this possible? > > Thanks! > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >You can use find(:first, :select => "DISTINCT *") Bojan -- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org
On Jun 20, 2006, at 11:53 AM, Daniel Higginbotham wrote:> I''m looking through the api for something like find(:all, :distinct > => true) > so that multiple instances of a row won''t be returned - is this > possible?You may specify the :uniq => true (the spelling of uniq matches Ruby''s Array#uniq) option for has_many and has_and_belongs_to_many associations. jeremy
Great thanks! -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Bojan Mihelac Sent: Tuesday, June 20, 2006 9:58 AM To: rails@lists.rubyonrails.org Subject: Re: [Rails] return unique rows with finders Daniel Higginbotham wrote:> I''m looking through the api for something like find(:all, :distinct =>true)> so that multiple instances of a row won''t be returned - is this possible? > > Thanks! > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >You can use find(:first, :select => "DISTINCT *") Bojan -- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails