views:

48

answers:

1

I have this

 @project.posts.count
=> 11
@project.articles.count
=> 5
>> a = @project.articles.map(&:signup_id)
=> [6, 8, 10, 12, 14]

I want to only display the project posts that dont have an id of the following [6, 8, 10, 12, 14]. So i want display the posts that dont have an article.signup_id

   @project.posts #so reject if id is  [6, 8, 10, 12, 14]

there is a relationship between them and i would like to do this

 @project.posts.find( :all, :include => [:articles], :conditions => 'articles.signup_id is null'

but its not filtering as i assumed

+2  A: 

Create a scope on the Post model.

class Post < ActiveRecord::Base

    named_scope :no_signup, :include => :article, :conditions => "articles.signup_id is null or articles.signup_id = ''"

end

I added that extra blank check in there because you said your find wasn't working right. Check to make sure those rows are not blank or set to some default value (like zero).

AKWF