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 I'm interested in finding I would like to complete it without SQL, even if it is something like this: 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 user Do: >
has_many: projects
has_one: thing
has_many: things
projects - either
things > (things: (condition :: full)) or (things: {id: blue}) < P> or
projects.includes (: thing). Where (Things: {{status :: full}, {id: zero}]
query = projects.includes (: thing) query.where (things: {id: blue}) & Query.where (Things: {condition :: full}) < / Pre>
Comments
Post a Comment