sql - Get all records with child records OR field length > 250 -


i have comment model has-many attachments. want return, of comments either have 1 or more attachment records, or comment longer 250 characters.

is there way can without writing entirely in pure sql? i'm struggling build clause in rails method. it's not quite simple i'd hoped :(

ideally want scope whatever work fine

you try:

comment.includes(:attachments).where('attachments.comment_id not null or len(comments.content) > 250') 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -