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
>
>
Try using Join Conditions

self.join(:news_categories).on(new_categories[:id].not(Category.sport.id<http://category.sport.id/>
))

I may be wrong on the Arel part, but in SQL it would be

SELECT * from news JOIN news_categories ON news_categories.id != x

-- 
Best regards,
Y. Thong Kuah

-- 
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