Finding records when using has_many through associations
        Posted  
        
            by winter sun
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by winter sun
        
        
        
        Published on 2010-05-30T14:17:22Z
        Indexed on 
            2010/05/30
            14:22 UTC
        
        
        Read the original article
        Hit count: 197
        
ruby-on-rails
I have two models, Worker and Project, and they are connected with has_many through association.
I manage to find all the projects which are related to a specific worker by writing the following code:
worker=Worker.find_by_id("some_id") 
worker.projects 
but I want the projects that I get to be only active projects (in the project model I have a status field)
I tried to do something like
worker.projects(:status_id=>'active')
but it didn’t work for me.
Can somebody tell me how I can do this?
© Stack Overflow or respective owner