From 1178dea355bf88213f5b36fae8914af6385b341a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 6 Mar 2014 15:06:19 -0500 Subject: tournaments: fix game selection --- app/controllers/tournaments_controller.rb | 4 ++-- app/views/tournaments/new.html.erb | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 1d17205..915c072 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -15,8 +15,8 @@ class TournamentsController < ApplicationController # GET /tournaments/new def new - @game_names = Game.all.collect - @game = params[:game] + @games = Game.all + @game = Game.find_by_id(params[:game]) @tournament = Tournament.new end diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb index 428487a..6c3fefc 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -1,19 +1,16 @@ -<%= javascript_include_tag :defaults %> -

New Tournament

-<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %> <%= link_to 'Select', 'new?game=1', :class => "btn btn-warning btn-lg" %> - +<%= form_tag(new_tournament_path, method: "get") do %> + <%= select_tag('game', + options_from_collection_for_select(@games, 'id', 'name', @game.nil? || @game.id), + :prompt => "Select a Game Type") %> + <%= submit_tag("Select", :class => "btn-warning btn-lg") %> +<% end %> - -
- <% if not @game.nil? %> + <% unless @game.nil? %> <%= render 'selected' %> <% end %>
-

- -<%= link_to 'Select', 'selected', :class => "btn btn-warning btn-lg" %> <%= link_to 'Back', tournaments_path %> -- cgit v1.2.3-2-g168b