ruby on rails - Is it possible to achieve 'or' in Active Record with an 'includes'? -
I am trying to query from within an ActiveRecord model, let's call it user Do:
User has_many: projects
Project has_one: thing
User has_many: things I'm interested in finding projects - either things (things: (condition :: full)) or (things: {id: blue}) < P> or
projects.includes (: thing). Where (Things: {{status :: full}, {id: zero}] I would like to complete it without SQL, even if it is something like this:
query = projects.includes (: thing) query.where (things: {id: blue}) & Query.where (Things: {condition :: full}) < / Pre>
then it may or may not work for you, but try
Query = projects.includes (: thing) query.where (things: {id: nil}) Joins (query.where (things: {status :: complete}))
I myself It can not be tested, but I I'm curious if it really connects together in two questions. I'll play with it later
Comments
Post a Comment