diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-06 18:55:38 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-06 18:55:38 -0500 |
commit | 1788dde36e53c4ef16adc5db2d19f44797325496 (patch) | |
tree | 4d331750a288fcdc052df2ae7dff19c68cd24151 /app/views | |
parent | 39f373778e73c54952dddd11e87f4ba354471622 (diff) |
implement tournament joining
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/tournaments/_selected.html.erb | 32 | ||||
-rw-r--r-- | app/views/tournaments/new.html.erb | 4 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 6 |
3 files changed, 16 insertions, 26 deletions
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index 4277d8e..551dc40 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -1,31 +1,15 @@ <%= form_for(@tournament) do |f| %> - <% if @tournament.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@tournament.errors.count, "error") %> prohibited this tournament from being saved:</h2> + <%= render "common/error_messages", :target => @tournament %> + <%= f.hidden_field(:game_id) %> - <ul> - <% @tournament.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> - - <%# this is the dynamic script to output fields to the form %> - <% @chosen = Game.find(@game) %> - <% @chosen.attributes.each do |name, value| %> - <% if name == "id" %> + <% @tournament.attributes.each do |name, value| %> + <% if (name == "id") or (name =~ /.*_at$/) %> <% next %> <% end %> - <% if name == "created_at" %> - <% break %> - <% end %> - <p> - <label for=<%= name %>><%= name.capitalize.gsub('_', ' ') %></label> - <br /> - <input type="text" id=<%= name %> value=<%= value %>> - </p> + <p> + <%= f.label name %><br> + <%= f.text_field name %> + </p> <% end %> - <%= f.submit %> <% end %> diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb index 6c3fefc..e007e31 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -2,13 +2,13 @@ <%= form_tag(new_tournament_path, method: "get") do %> <%= select_tag('game', - options_from_collection_for_select(@games, 'id', 'name', @game.nil? || @game.id), + options_from_collection_for_select(@games, 'id', 'name', @tournament.game.nil? || @tournament.game.id), :prompt => "Select a Game Type") %> <%= submit_tag("Select", :class => "btn-warning btn-lg") %> <% end %> <div id='ajax-form'> - <% unless @game.nil? %> + <% unless @tournament.game.nil? %> <%= render 'selected' %> <% end %> </div> diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 0d9dd10..1470d80 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,3 +1,9 @@ +<% if @tournament.joinable_by?(current_user) %> + <%= form_tag(tournament_page(@tournament)+"/join", method: "get") do %> + <%= submit_tag("Join") %> + <% end %> +<% end %> + <p> <strong>Game:</strong> <%= @tournament.game %> |