Can you post the SQL that AR is generating when you run the query?

On Wed, Aug 25, 2010 at 11:03 AM, Richard Hulse
<[email protected]>wrote:

> Hi,
>
> I am trying to get a list of unique items under the current scenario
> (Rails3):
>
> A 'News' item:
>
>  has_many :categories, :through => :news_categories
>
> I am getting a group of stories thus:
>
> def self.news_feed_stories
>   joins(:news_categories).
>   where("news_categories.id != ?", Category.sport.id).
>   where("news_categories.id != ?", Category.top.id).
>   order('sort_order desc')
>  end
>
> But there are duplicates when a story is in two categories.
>
> I tried adding:
>
>   select("DISTINCT('news.*')").
>
> but I get back no stories.
>
>
>
> cheers,
>
> Richard
>
> --
> You received this message because you are subscribed to the Google Groups
> "WellRailed" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<wellrailed%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/wellrailed?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"WellRailed" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/wellrailed?hl=en.

Reply via email to