Rails - activerecord find using has_many relationship and conditions on the “many” side?

I guess the following should work: Activity. All(:include => :workflows, :joins => :workflows, :conditions => "workflows. Status!

= COMPLETED") (You are using rails 2 finder syntax, so I guess you are not using rails 3, right? ) UPDATED Activity. All(:include => :workflows, :conditions => "workflows.

Status! = 'COMPLETED'") It seems like rails 2 will do a outer join for :include so no need to use :joins anymore Also, the COMPLETED should be quoted by Hope this works for you!

Have you tried to see the generated sql statement by using . To_sql? I guess the following should work: Activity.

All(:include => :workflows, :joins => :workflows, :conditions => "workflows. Status! = COMPLETED") (You are using rails 2 finder syntax, so I guess you are not using rails 3, right?) ====== UPDATED ====== Activity.

All(:include => :workflows, :conditions => "workflows. Status! = 'COMPLETED'") It seems like rails 2 will do a outer join for :include, so no need to use :joins anymore.

Also, the COMPLETED should be quoted by '. Hope this works for you!

I couldn't get it to work...I tried your suggested code, but I get a mysql error complaining about non-unique table or aliases referring to workflows... – mmastera Aug 22 at 5:40 Oh, didn't know that to_sql is in rails 3 only. Maybe you could check the generated sql in the log file. I'm now creating a test project to reconstruct your problem.

– PeterWong Aug 22 at 6:57.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send