[Ruby] Distinct in Active Record

Tom Lianza tom at lianza.org
Wed Oct 17 16:43:17 PDT 2007


On 10/17/07, Neil Moomey <neil at motznik.com> wrote:
>
> How is this done in Active Record?
>
> select distinct * from table
>
> I can find distinct for calculate and count but not for :all.  Yes, I
> could
> use :group but I have 13 fields to group by.


I think you can just do:

YourModel.find(:all, :select=>'DISTINCT *')

ActiveRecord just slaps whatever is in that string into the select clause.

Neil
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>


More information about the Ruby mailing list