Finding records when using has_many through associations
- by winter sun
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?