I'm a beginner at Rails and SQL, so I'm sorry if there are any expressions that are difficult to understand.
First, we have the following models:
The Favorite model is an intermediate table with the User model centered on the City model.The Area model is an intermediate table with the Country model.
I would like to extract the matches between the City model and the Country model, and sort the extracted matches in order of the number of City models registered in the Favorite model.
For example, if you want to sort the extracted items in the Country model America, I wrote the following, but it doesn't work.
How can I do this?ruby-on-rails ruby rails-activerecord
Perhaps this is how it works.
© 2022 OneMinuteCode. All rights reserved.