私は2つのモデルを持っています:
class Country
has_many :competitions
end
class Competition
belongs_to :country
end
競技クラスには位置属性があります。管理者は、競技を順位別に並べ替えることができます。競争の最小の位置で国を並べ替えたいです。国との大会にも参加したいです。どうすればそれを達成できますか?
次のような出力が必要です。
X Country: (is at first order because Xcomp1's position is 1)
Xcomp1 (position: 1)
Xcomp2 (position: 12)
A Country:
Acomp1 (position:2)
Acomp2 (position:3)
Z Country: (is at last position because minimum position of its competitions are higher than other ones)
Zcomp1 (position:5)