jeudi 25 août 2022

Ruby on Rails ActiveRecord filter issue

I have a problem.

Problem description: I have table Projects and table Assets. I need show Projects only where model_aseets is exists only.

Example code My query:

select  s3_object_key,  a.id from projects
left join assets a on projects.id = a.project_id
where asset_category =2
projects = Project.where(Asset.ar_model.exists)

Get an error:

"status": 500,
"error": "Internal Server Error",
“exception": "#<NoMethodError: undefined method `exists' for #<ActiveRecord::Relation

Could someone help, please. Thanks

Aucun commentaire:

Enregistrer un commentaire