Exclude some ids from result in Rails ActiveRecord

Posted by Beer Brother on Stack Overflow See other posts from Stack Overflow or by Beer Brother
Published on 2010-04-05T20:28:49Z Indexed on 2010/04/05 20:33 UTC
Read the original article Hit count: 152

Filed under:
|
|

I have following statement for query articles from some sections

Article.all(:joins => :sections, :conditions => { :sections =>{ :id => [3, 4, 6, 7, 8, 9] }, :id_not_in => @some_ids  }, :limit => 4)

Variable @some_ids is array with ids of articles wich must be excluded from result.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails