summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-03-04 18:57:50 -0500
committerAndrewMurrell <amurrel@purdue.edu>2014-03-04 18:57:50 -0500
commite586c3e2b30698ea5a1c83c19ea446c4be89fd54 (patch)
tree749a343dbcd93f461930e8c6ff11ebb41f2af8da
parent4cdd4e361ad691d524f9ee6163b40ef78d9938c4 (diff)
Here's to messing everything up.
-rw-r--r--app/assets/javascripts/ajax.js6
-rw-r--r--app/controllers/tournaments_controller.rb9
-rw-r--r--app/views/tournaments/_selected.html.erb30
-rw-r--r--app/views/tournaments/index.html.erb27
-rw-r--r--app/views/tournaments/new.html.erb12
-rw-r--r--config/routes.rb2
-rwxr-xr-xstart.sh2
7 files changed, 52 insertions, 36 deletions
diff --git a/app/assets/javascripts/ajax.js b/app/assets/javascripts/ajax.js
index 31578dd..040c100 100644
--- a/app/assets/javascripts/ajax.js
+++ b/app/assets/javascripts/ajax.js
@@ -12,4 +12,8 @@ function populate() {
;
}
};
-} \ No newline at end of file
+
+//$.ajax(url: "/selected").done (html) -> $("#ajax-form").append html
+
+}
+
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 27ba020..5c53693 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -15,6 +15,7 @@ class TournamentsController < ApplicationController
# GET /tournaments/new
def new
@game_names = Game.all.collect
+ @game = params[:game]
@tournament = Tournament.new
end
@@ -22,12 +23,6 @@ class TournamentsController < ApplicationController
def edit
end
- def selected
- render :update do |page|
- page.replace_html 'ajax-form', :partial => 'selected'
- end
- end
-
# POST /tournaments
# POST /tournaments.json
def create
@@ -76,6 +71,6 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game_id)
+ params.require(:tournament).permit(:game_id, :game)
end
end
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
index 302283d..3b14404 100644
--- a/app/views/tournaments/_selected.html.erb
+++ b/app/views/tournaments/_selected.html.erb
@@ -1,25 +1,5 @@
-<form accept-charset="UTF-8" action="/users" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="6WQoPLFISlDYCsi4LhAgT0hgrht19yydD3w5TlKfb7I=" /></div>
- <p>
- <label for="GameType">Game</label><br>
- <input id="GameType" name="League of Legends" type="text" />
- </p>
- <p>
- <label for="players_per_team">Number of Players</label><br>
- <input id="players_per_team" name="5" type="text" />
- </p>
- <p>
- <label for="teams_per_match">Teams per Match</label><br>
- <input id="teams_per_match" name="2" type="text" />
- </p>
- <p>
- <label for="set_rounds">Set Number of Rounds?</label><br>
- <input id="set_rounds" name="1" type="text" />
- </p>
- <p>
- <label for="randomized_teams">Randomized Teams?</label><br>
- <input id="randomized_teams" name="0" type="text" />
- </p>
- <p>
- <input name="create" type="submit" value="Create Tournament" />
- </p>
-</form> \ No newline at end of file
+
+ <%= content_tag(:p, "Hello World") %>
+
+
+<%= tag(:label, for: 'GameType') %> \ No newline at end of file
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
new file mode 100644
index 0000000..26d0643
--- /dev/null
+++ b/app/views/tournaments/index.html.erb
@@ -0,0 +1,27 @@
+<h1>Listing tournaments</h1>
+
+<table>
+ <thead>
+ <tr>
+ <th>Tournament ID</th>
+ <th>Show Tournament</th>
+ <th>Edit Tournament</th>
+ <th>Delete Tournament</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% @tournaments.each do |tournament| %>
+ <tr>
+ <td><%= tournament.id %></td>
+ <td><%= link_to 'Show', tournament %></td>
+ <td><%= link_to 'Edit', edit_tournament_path(tournament) %></td>
+ <td><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Tournament', new_tournament_path, :class => "btn btn-warning btn-lg" %>
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index f1dec90..a6dfa4d 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -1,11 +1,19 @@
+<%= javascript_include_tag :defaults %>
+
<h1>New tournament</h1>
-<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %>
+<%= 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" %>
+
+
<br />
<div id='ajax-form'>
- <% render :partial => "selected" %>
+ <% if not @game.nil? %>
+ <%= render 'selected' %>
+ <% end %>
</div>
<br /><br />
+<%= link_to 'Select', 'selected', :class => "btn btn-warning btn-lg" %>
+
<%= link_to 'Back', tournaments_path %>
diff --git a/config/routes.rb b/config/routes.rb
index 022ce42..2409eb2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -17,6 +17,8 @@ Leaguer::Application.routes.draw do
resources :tournaments
+ #set 'selected' to: 'tournaments#selected' via: 'get'
+
resources :servers
root to: 'static#homepage'
diff --git a/start.sh b/start.sh
index cb9cdda..2b58327 100755
--- a/start.sh
+++ b/start.sh
@@ -1,4 +1,4 @@
#!/bin/bash
-nohup bundle exec rails server &
+bundle exec rails server --daemon