sql - How to check if record does NOT exist in Rails 5 with active record querying? -


i have article model , comments model. how list of articles not have comments using active record?

model columns:

article: body:string (has many comments)

comment: body:string, article_id:integer (belongs article)

if want result using single query , want result activerecord relation, use:

article.where('id not in (select distinct(article_id) comments)') 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -