diff --git a/lib/rank_king/models.rb b/lib/rank_king/models.rb index c706bfb..e882c62 100644 --- a/lib/rank_king/models.rb +++ b/lib/rank_king/models.rb @@ -35,7 +35,7 @@ module RankKing class Ranking < Sequel::Model many_to_one :axis - many_to_one :winner, class: :Item - many_to_one :loser, class: :Item + many_to_one :winner, class: "RankKing::Item" + many_to_one :loser, class: "RankKing::Item" end end diff --git a/lib/web.rb b/lib/web.rb index 499085b..e200823 100644 --- a/lib/web.rb +++ b/lib/web.rb @@ -55,6 +55,18 @@ module RankKing <% end %> + +
+ <% @game.each.with_index do |item, i| %> + + + <% end %> + +
ERB route do |r| @@ -76,10 +88,22 @@ module RankKing end r.on "axes" do - r.is Integer do |id| + r.on Integer do |id| @axis = Axis[id] - view :axis + r.is "rank" do + items = r.params.values_at("item_0", "item_1").map { Item[_1] } + winner, loser = items.partition { _1.id == r.params.fetch("winner").to_i }.flatten + RankKing.rank(@axis, winner:, loser:) + + r.redirect "/pools/#{@pool.id}/axes/#{@axis.id}" + end + + r.is do + @game = RankKing.suggest_game(@axis).shuffle + + view :axis + end end end end