From 8e3e88f52c1f2d73acdcb7fdf60326b5f7717068 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Wed, 26 Feb 2014 20:07:42 -0500 Subject: Possibly broke everything. Added another model for populating tournament options. --- app/models/tournament_options.rb | 2 ++ db/migrate/20140304014838_create_servers.rb | 8 -------- db/migrate/20140304014840_create_tournaments.rb | 8 -------- db/migrate/20140304014842_create_matches.rb | 9 --------- db/migrate/20140304014844_create_teams.rb | 8 -------- db/migrate/20140304014846_create_users.rb | 11 ----------- db/migrate/20140304014848_create_user_team_pairs.rb | 10 ---------- db/migrate/20140304014850_create_team_match_pairs.rb | 10 ---------- db/migrate/20140304014852_create_alerts.rb | 10 ---------- db/migrate/20140304014855_create_pms.rb | 11 ----------- db/migrate/20140304014857_create_server_settings.rb | 8 -------- db/migrate/20140304014940_create_servers.rb | 8 ++++++++ db/migrate/20140304014942_create_tournaments.rb | 8 ++++++++ db/migrate/20140304014944_create_matches.rb | 9 +++++++++ db/migrate/20140304014946_create_teams.rb | 8 ++++++++ db/migrate/20140304014948_create_users.rb | 11 +++++++++++ db/migrate/20140304014950_create_user_team_pairs.rb | 10 ++++++++++ db/migrate/20140304014952_create_team_match_pairs.rb | 10 ++++++++++ db/migrate/20140304014954_create_alerts.rb | 10 ++++++++++ db/migrate/20140304014957_create_pms.rb | 11 +++++++++++ db/migrate/20140304014959_create_server_settings.rb | 8 ++++++++ db/migrate/20140304015005_create_tournament_options.rb | 8 ++++++++ db/schema.rb | 7 ++++++- generate.sh | 8 +++++++- test/fixtures/tournament_options.yml | 11 +++++++++++ test/models/tournament_options_test.rb | 7 +++++++ 26 files changed, 134 insertions(+), 95 deletions(-) create mode 100644 app/models/tournament_options.rb delete mode 100644 db/migrate/20140304014838_create_servers.rb delete mode 100644 db/migrate/20140304014840_create_tournaments.rb delete mode 100644 db/migrate/20140304014842_create_matches.rb delete mode 100644 db/migrate/20140304014844_create_teams.rb delete mode 100644 db/migrate/20140304014846_create_users.rb delete mode 100644 db/migrate/20140304014848_create_user_team_pairs.rb delete mode 100644 db/migrate/20140304014850_create_team_match_pairs.rb delete mode 100644 db/migrate/20140304014852_create_alerts.rb delete mode 100644 db/migrate/20140304014855_create_pms.rb delete mode 100644 db/migrate/20140304014857_create_server_settings.rb create mode 100644 db/migrate/20140304014940_create_servers.rb create mode 100644 db/migrate/20140304014942_create_tournaments.rb create mode 100644 db/migrate/20140304014944_create_matches.rb create mode 100644 db/migrate/20140304014946_create_teams.rb create mode 100644 db/migrate/20140304014948_create_users.rb create mode 100644 db/migrate/20140304014950_create_user_team_pairs.rb create mode 100644 db/migrate/20140304014952_create_team_match_pairs.rb create mode 100644 db/migrate/20140304014954_create_alerts.rb create mode 100644 db/migrate/20140304014957_create_pms.rb create mode 100644 db/migrate/20140304014959_create_server_settings.rb create mode 100644 db/migrate/20140304015005_create_tournament_options.rb create mode 100644 test/fixtures/tournament_options.yml create mode 100644 test/models/tournament_options_test.rb diff --git a/app/models/tournament_options.rb b/app/models/tournament_options.rb new file mode 100644 index 0000000..8ed6433 --- /dev/null +++ b/app/models/tournament_options.rb @@ -0,0 +1,2 @@ +class TournamentOptions < ActiveRecord::Base +end diff --git a/db/migrate/20140304014838_create_servers.rb b/db/migrate/20140304014838_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140304014838_create_servers.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014840_create_tournaments.rb b/db/migrate/20140304014840_create_tournaments.rb deleted file mode 100644 index 2095590..0000000 --- a/db/migrate/20140304014840_create_tournaments.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014842_create_matches.rb b/db/migrate/20140304014842_create_matches.rb deleted file mode 100644 index 6c0c157..0000000 --- a/db/migrate/20140304014842_create_matches.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014844_create_teams.rb b/db/migrate/20140304014844_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140304014844_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014846_create_users.rb b/db/migrate/20140304014846_create_users.rb deleted file mode 100644 index 6a500e5..0000000 --- a/db/migrate/20140304014846_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.text :name - t.text :pw_hash - t.integer :groups - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014848_create_user_team_pairs.rb b/db/migrate/20140304014848_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140304014848_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014850_create_team_match_pairs.rb b/db/migrate/20140304014850_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140304014850_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014852_create_alerts.rb b/db/migrate/20140304014852_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140304014852_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014855_create_pms.rb b/db/migrate/20140304014855_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140304014855_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014857_create_server_settings.rb b/db/migrate/20140304014857_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140304014857_create_server_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServerSettings < ActiveRecord::Migration - def change - create_table :server_settings do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014940_create_servers.rb b/db/migrate/20140304014940_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140304014940_create_servers.rb @@ -0,0 +1,8 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014942_create_tournaments.rb b/db/migrate/20140304014942_create_tournaments.rb new file mode 100644 index 0000000..2095590 --- /dev/null +++ b/db/migrate/20140304014942_create_tournaments.rb @@ -0,0 +1,8 @@ +class CreateTournaments < ActiveRecord::Migration + def change + create_table :tournaments do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014944_create_matches.rb b/db/migrate/20140304014944_create_matches.rb new file mode 100644 index 0000000..6c0c157 --- /dev/null +++ b/db/migrate/20140304014944_create_matches.rb @@ -0,0 +1,9 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014946_create_teams.rb b/db/migrate/20140304014946_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140304014946_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014948_create_users.rb b/db/migrate/20140304014948_create_users.rb new file mode 100644 index 0000000..6a500e5 --- /dev/null +++ b/db/migrate/20140304014948_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.text :name + t.text :pw_hash + t.integer :groups + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014950_create_user_team_pairs.rb b/db/migrate/20140304014950_create_user_team_pairs.rb new file mode 100644 index 0000000..2c492ac --- /dev/null +++ b/db/migrate/20140304014950_create_user_team_pairs.rb @@ -0,0 +1,10 @@ +class CreateUserTeamPairs < ActiveRecord::Migration + def change + create_table :user_team_pairs do |t| + t.references :user, index: true + t.references :team, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014952_create_team_match_pairs.rb b/db/migrate/20140304014952_create_team_match_pairs.rb new file mode 100644 index 0000000..8fac07e --- /dev/null +++ b/db/migrate/20140304014952_create_team_match_pairs.rb @@ -0,0 +1,10 @@ +class CreateTeamMatchPairs < ActiveRecord::Migration + def change + create_table :team_match_pairs do |t| + t.references :team, index: true + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014954_create_alerts.rb b/db/migrate/20140304014954_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140304014954_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014957_create_pms.rb b/db/migrate/20140304014957_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140304014957_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304014959_create_server_settings.rb b/db/migrate/20140304014959_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140304014959_create_server_settings.rb @@ -0,0 +1,8 @@ +class CreateServerSettings < ActiveRecord::Migration + def change + create_table :server_settings do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015005_create_tournament_options.rb b/db/migrate/20140304015005_create_tournament_options.rb new file mode 100644 index 0000000..d2df22e --- /dev/null +++ b/db/migrate/20140304015005_create_tournament_options.rb @@ -0,0 +1,8 @@ +class CreateTournamentOptions < ActiveRecord::Migration + def change + create_table :tournament_options do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 88dfa1a..9d307ae 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140304014857) do +ActiveRecord::Schema.define(version: 20140304015005) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -66,6 +66,11 @@ ActiveRecord::Schema.define(version: 20140304014857) do t.datetime "updated_at" end + create_table "tournament_options", force: true do |t| + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "tournaments", force: true do |t| t.datetime "created_at" t.datetime "updated_at" diff --git a/generate.sh b/generate.sh index 666869c..52d0f90 100755 --- a/generate.sh +++ b/generate.sh @@ -4,7 +4,8 @@ # To Start Rails Server: # bundle exec rails server # -# +# To Clear the Generated Files: +# # set -x @@ -20,6 +21,11 @@ bundle exec rails generate scaffold pm author:references recipient:references me bundle exec rails generate model server_settings bundle exec rails generate controller search bundle exec rails generate controller main + +#for the tournament controller to generate options +bundle exec rails generate model tournament_options + bundle exec rake db:drop RAILS_ENV=development bundle exec rake db:migrate RAILS_ENV=development + #bundle exec rails generate scaffold diff --git a/test/fixtures/tournament_options.yml b/test/fixtures/tournament_options.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/tournament_options.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/tournament_options_test.rb b/test/models/tournament_options_test.rb new file mode 100644 index 0000000..7677fae --- /dev/null +++ b/test/models/tournament_options_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class TournamentOptionsTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end -- cgit v1.2.3 From 3a7b14f4a51c0fdb8b71720f361a0a8ccf080325 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 27 Feb 2014 16:59:04 -0500 Subject: add game types --- app/assets/javascripts/games.js.coffee | 3 + app/assets/stylesheets/games.css.scss | 3 + app/controllers/games_controller.rb | 74 ++++++++++++++++++++++ app/helpers/games_helper.rb | 2 + app/models/game.rb | 2 + app/models/game_attribute.rb | 3 + app/views/games/_form.html.erb | 21 ++++++ app/views/games/edit.html.erb | 6 ++ app/views/games/index.html.erb | 27 ++++++++ app/views/games/index.json.jbuilder | 4 ++ app/views/games/new.html.erb | 5 ++ app/views/games/show.html.erb | 9 +++ app/views/games/show.json.jbuilder | 1 + config/routes.rb | 2 + db/migrate/20140304014940_create_servers.rb | 8 --- db/migrate/20140304014942_create_tournaments.rb | 8 --- db/migrate/20140304014944_create_matches.rb | 9 --- db/migrate/20140304014946_create_teams.rb | 8 --- db/migrate/20140304014948_create_users.rb | 11 ---- .../20140304014950_create_user_team_pairs.rb | 10 --- .../20140304014952_create_team_match_pairs.rb | 10 --- db/migrate/20140304014954_create_alerts.rb | 10 --- db/migrate/20140304014957_create_pms.rb | 11 ---- .../20140304014959_create_server_settings.rb | 8 --- .../20140304015005_create_tournament_options.rb | 8 --- db/migrate/20140304015013_create_servers.rb | 8 +++ db/migrate/20140304015015_create_tournaments.rb | 8 +++ db/migrate/20140304015017_create_matches.rb | 9 +++ db/migrate/20140304015019_create_teams.rb | 8 +++ db/migrate/20140304015021_create_users.rb | 11 ++++ .../20140304015023_create_user_team_pairs.rb | 10 +++ .../20140304015026_create_team_match_pairs.rb | 10 +++ db/migrate/20140304015028_create_alerts.rb | 10 +++ db/migrate/20140304015030_create_pms.rb | 11 ++++ db/migrate/20140304015032_create_games.rb | 9 +++ .../20140304015034_create_game_attributes.rb | 11 ++++ .../20140304015036_create_server_settings.rb | 8 +++ .../20140304015042_create_tournament_options.rb | 8 +++ db/schema.rb | 18 +++++- generate.sh | 4 +- test/controllers/games_controller_test.rb | 49 ++++++++++++++ test/fixtures/game_attributes.yml | 11 ++++ test/fixtures/games.yml | 7 ++ test/helpers/games_helper_test.rb | 4 ++ test/models/game_attribute_test.rb | 7 ++ test/models/game_test.rb | 7 ++ 46 files changed, 388 insertions(+), 103 deletions(-) create mode 100644 app/assets/javascripts/games.js.coffee create mode 100644 app/assets/stylesheets/games.css.scss create mode 100644 app/controllers/games_controller.rb create mode 100644 app/helpers/games_helper.rb create mode 100644 app/models/game.rb create mode 100644 app/models/game_attribute.rb create mode 100644 app/views/games/_form.html.erb create mode 100644 app/views/games/edit.html.erb create mode 100644 app/views/games/index.html.erb create mode 100644 app/views/games/index.json.jbuilder create mode 100644 app/views/games/new.html.erb create mode 100644 app/views/games/show.html.erb create mode 100644 app/views/games/show.json.jbuilder delete mode 100644 db/migrate/20140304014940_create_servers.rb delete mode 100644 db/migrate/20140304014942_create_tournaments.rb delete mode 100644 db/migrate/20140304014944_create_matches.rb delete mode 100644 db/migrate/20140304014946_create_teams.rb delete mode 100644 db/migrate/20140304014948_create_users.rb delete mode 100644 db/migrate/20140304014950_create_user_team_pairs.rb delete mode 100644 db/migrate/20140304014952_create_team_match_pairs.rb delete mode 100644 db/migrate/20140304014954_create_alerts.rb delete mode 100644 db/migrate/20140304014957_create_pms.rb delete mode 100644 db/migrate/20140304014959_create_server_settings.rb delete mode 100644 db/migrate/20140304015005_create_tournament_options.rb create mode 100644 db/migrate/20140304015013_create_servers.rb create mode 100644 db/migrate/20140304015015_create_tournaments.rb create mode 100644 db/migrate/20140304015017_create_matches.rb create mode 100644 db/migrate/20140304015019_create_teams.rb create mode 100644 db/migrate/20140304015021_create_users.rb create mode 100644 db/migrate/20140304015023_create_user_team_pairs.rb create mode 100644 db/migrate/20140304015026_create_team_match_pairs.rb create mode 100644 db/migrate/20140304015028_create_alerts.rb create mode 100644 db/migrate/20140304015030_create_pms.rb create mode 100644 db/migrate/20140304015032_create_games.rb create mode 100644 db/migrate/20140304015034_create_game_attributes.rb create mode 100644 db/migrate/20140304015036_create_server_settings.rb create mode 100644 db/migrate/20140304015042_create_tournament_options.rb create mode 100644 test/controllers/games_controller_test.rb create mode 100644 test/fixtures/game_attributes.yml create mode 100644 test/fixtures/games.yml create mode 100644 test/helpers/games_helper_test.rb create mode 100644 test/models/game_attribute_test.rb create mode 100644 test/models/game_test.rb diff --git a/app/assets/javascripts/games.js.coffee b/app/assets/javascripts/games.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/games.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/games.css.scss b/app/assets/stylesheets/games.css.scss new file mode 100644 index 0000000..db1b7bc --- /dev/null +++ b/app/assets/stylesheets/games.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the games controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb new file mode 100644 index 0000000..0a9d8e8 --- /dev/null +++ b/app/controllers/games_controller.rb @@ -0,0 +1,74 @@ +class GamesController < ApplicationController + before_action :set_game, only: [:show, :edit, :update, :destroy] + + # GET /games + # GET /games.json + def index + @games = Game.all + end + + # GET /games/1 + # GET /games/1.json + def show + end + + # GET /games/new + def new + @game = Game.new + end + + # GET /games/1/edit + def edit + end + + # POST /games + # POST /games.json + def create + @game = Game.new(game_params) + + respond_to do |format| + if @game.save + format.html { redirect_to @game, notice: 'Game was successfully created.' } + format.json { render action: 'show', status: :created, location: @game } + else + format.html { render action: 'new' } + format.json { render json: @game.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /games/1 + # PATCH/PUT /games/1.json + def update + respond_to do |format| + if @game.update(game_params) + format.html { redirect_to @game, notice: 'Game was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @game.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /games/1 + # DELETE /games/1.json + def destroy + @game.destroy + respond_to do |format| + format.html { redirect_to games_url } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_game + @game = Game.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def game_params + params.require(:game).permit(:name) + end +end diff --git a/app/helpers/games_helper.rb b/app/helpers/games_helper.rb new file mode 100644 index 0000000..2ef8c1f --- /dev/null +++ b/app/helpers/games_helper.rb @@ -0,0 +1,2 @@ +module GamesHelper +end diff --git a/app/models/game.rb b/app/models/game.rb new file mode 100644 index 0000000..a181c26 --- /dev/null +++ b/app/models/game.rb @@ -0,0 +1,2 @@ +class Game < ActiveRecord::Base +end diff --git a/app/models/game_attribute.rb b/app/models/game_attribute.rb new file mode 100644 index 0000000..c12723b --- /dev/null +++ b/app/models/game_attribute.rb @@ -0,0 +1,3 @@ +class GameAttribute < ActiveRecord::Base + belongs_to :game +end diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb new file mode 100644 index 0000000..0bbdd1f --- /dev/null +++ b/app/views/games/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for(@game) do |f| %> + <% if @game.errors.any? %> +
+

<%= pluralize(@game.errors.count, "error") %> prohibited this game from being saved:

+ +
    + <% @game.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_area :name %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/games/edit.html.erb b/app/views/games/edit.html.erb new file mode 100644 index 0000000..d72bd2e --- /dev/null +++ b/app/views/games/edit.html.erb @@ -0,0 +1,6 @@ +

Editing game

+ +<%= render 'form' %> + +<%= link_to 'Show', @game %> | +<%= link_to 'Back', games_path %> diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb new file mode 100644 index 0000000..27d47b6 --- /dev/null +++ b/app/views/games/index.html.erb @@ -0,0 +1,27 @@ +

Listing games

+ + + + + + + + + + + + + <% @games.each do |game| %> + + + + + + + <% end %> + +
Name
<%= game.name %><%= link_to 'Show', game %><%= link_to 'Edit', edit_game_path(game) %><%= link_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Game', new_game_path %> diff --git a/app/views/games/index.json.jbuilder b/app/views/games/index.json.jbuilder new file mode 100644 index 0000000..90f4236 --- /dev/null +++ b/app/views/games/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@games) do |game| + json.extract! game, :id, :name + json.url game_url(game, format: :json) +end diff --git a/app/views/games/new.html.erb b/app/views/games/new.html.erb new file mode 100644 index 0000000..ab95f70 --- /dev/null +++ b/app/views/games/new.html.erb @@ -0,0 +1,5 @@ +

New game

+ +<%= render 'form' %> + +<%= link_to 'Back', games_path %> diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb new file mode 100644 index 0000000..20d374f --- /dev/null +++ b/app/views/games/show.html.erb @@ -0,0 +1,9 @@ +

<%= notice %>

+ +

+ Name: + <%= @game.name %> +

+ +<%= link_to 'Edit', edit_game_path(@game) %> | +<%= link_to 'Back', games_path %> diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder new file mode 100644 index 0000000..a4d8d1c --- /dev/null +++ b/app/views/games/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @game, :id, :name, :created_at, :updated_at diff --git a/config/routes.rb b/config/routes.rb index f13c891..3412005 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Leaguer::Application.routes.draw do + resources :games + resources :pms resources :alerts diff --git a/db/migrate/20140304014940_create_servers.rb b/db/migrate/20140304014940_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140304014940_create_servers.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014942_create_tournaments.rb b/db/migrate/20140304014942_create_tournaments.rb deleted file mode 100644 index 2095590..0000000 --- a/db/migrate/20140304014942_create_tournaments.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014944_create_matches.rb b/db/migrate/20140304014944_create_matches.rb deleted file mode 100644 index 6c0c157..0000000 --- a/db/migrate/20140304014944_create_matches.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014946_create_teams.rb b/db/migrate/20140304014946_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140304014946_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014948_create_users.rb b/db/migrate/20140304014948_create_users.rb deleted file mode 100644 index 6a500e5..0000000 --- a/db/migrate/20140304014948_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.text :name - t.text :pw_hash - t.integer :groups - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014950_create_user_team_pairs.rb b/db/migrate/20140304014950_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140304014950_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014952_create_team_match_pairs.rb b/db/migrate/20140304014952_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140304014952_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014954_create_alerts.rb b/db/migrate/20140304014954_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140304014954_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014957_create_pms.rb b/db/migrate/20140304014957_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140304014957_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304014959_create_server_settings.rb b/db/migrate/20140304014959_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140304014959_create_server_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServerSettings < ActiveRecord::Migration - def change - create_table :server_settings do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015005_create_tournament_options.rb b/db/migrate/20140304015005_create_tournament_options.rb deleted file mode 100644 index d2df22e..0000000 --- a/db/migrate/20140304015005_create_tournament_options.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentOptions < ActiveRecord::Migration - def change - create_table :tournament_options do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015013_create_servers.rb b/db/migrate/20140304015013_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140304015013_create_servers.rb @@ -0,0 +1,8 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015015_create_tournaments.rb b/db/migrate/20140304015015_create_tournaments.rb new file mode 100644 index 0000000..2095590 --- /dev/null +++ b/db/migrate/20140304015015_create_tournaments.rb @@ -0,0 +1,8 @@ +class CreateTournaments < ActiveRecord::Migration + def change + create_table :tournaments do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015017_create_matches.rb b/db/migrate/20140304015017_create_matches.rb new file mode 100644 index 0000000..6c0c157 --- /dev/null +++ b/db/migrate/20140304015017_create_matches.rb @@ -0,0 +1,9 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015019_create_teams.rb b/db/migrate/20140304015019_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140304015019_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015021_create_users.rb b/db/migrate/20140304015021_create_users.rb new file mode 100644 index 0000000..6a500e5 --- /dev/null +++ b/db/migrate/20140304015021_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.text :name + t.text :pw_hash + t.integer :groups + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015023_create_user_team_pairs.rb b/db/migrate/20140304015023_create_user_team_pairs.rb new file mode 100644 index 0000000..2c492ac --- /dev/null +++ b/db/migrate/20140304015023_create_user_team_pairs.rb @@ -0,0 +1,10 @@ +class CreateUserTeamPairs < ActiveRecord::Migration + def change + create_table :user_team_pairs do |t| + t.references :user, index: true + t.references :team, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015026_create_team_match_pairs.rb b/db/migrate/20140304015026_create_team_match_pairs.rb new file mode 100644 index 0000000..8fac07e --- /dev/null +++ b/db/migrate/20140304015026_create_team_match_pairs.rb @@ -0,0 +1,10 @@ +class CreateTeamMatchPairs < ActiveRecord::Migration + def change + create_table :team_match_pairs do |t| + t.references :team, index: true + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015028_create_alerts.rb b/db/migrate/20140304015028_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140304015028_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015030_create_pms.rb b/db/migrate/20140304015030_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140304015030_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015032_create_games.rb b/db/migrate/20140304015032_create_games.rb new file mode 100644 index 0000000..fc54709 --- /dev/null +++ b/db/migrate/20140304015032_create_games.rb @@ -0,0 +1,9 @@ +class CreateGames < ActiveRecord::Migration + def change + create_table :games do |t| + t.text :name + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015034_create_game_attributes.rb b/db/migrate/20140304015034_create_game_attributes.rb new file mode 100644 index 0000000..b63f134 --- /dev/null +++ b/db/migrate/20140304015034_create_game_attributes.rb @@ -0,0 +1,11 @@ +class CreateGameAttributes < ActiveRecord::Migration + def change + create_table :game_attributes do |t| + t.references :game, index: true + t.text :key + t.integer :type + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015036_create_server_settings.rb b/db/migrate/20140304015036_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140304015036_create_server_settings.rb @@ -0,0 +1,8 @@ +class CreateServerSettings < ActiveRecord::Migration + def change + create_table :server_settings do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015042_create_tournament_options.rb b/db/migrate/20140304015042_create_tournament_options.rb new file mode 100644 index 0000000..d2df22e --- /dev/null +++ b/db/migrate/20140304015042_create_tournament_options.rb @@ -0,0 +1,8 @@ +class CreateTournamentOptions < ActiveRecord::Migration + def change + create_table :tournament_options do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9d307ae..86afd1b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140304015005) do +ActiveRecord::Schema.define(version: 20140304015042) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -22,6 +22,22 @@ ActiveRecord::Schema.define(version: 20140304015005) do add_index "alerts", ["author_id"], name: "index_alerts_on_author_id" + create_table "game_attributes", force: true do |t| + t.integer "game_id" + t.text "key" + t.integer "type" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "game_attributes", ["game_id"], name: "index_game_attributes_on_game_id" + + create_table "games", force: true do |t| + t.text "name" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "matches", force: true do |t| t.integer "tournament_id" t.datetime "created_at" diff --git a/generate.sh b/generate.sh index 52d0f90..7dbb444 100755 --- a/generate.sh +++ b/generate.sh @@ -5,7 +5,7 @@ # bundle exec rails server # # To Clear the Generated Files: -# +# git clean -df # set -x @@ -18,6 +18,8 @@ bundle exec rails generate model user_team_pair user:references team:references bundle exec rails generate model team_match_pair team:references match:references bundle exec rails generate scaffold alert author:references message:text bundle exec rails generate scaffold pm author:references recipient:references message:text +bundle exec rails generate scaffold game name:text +bundle exec rails generate model game_attribute game:references key:text type:integer bundle exec rails generate model server_settings bundle exec rails generate controller search bundle exec rails generate controller main diff --git a/test/controllers/games_controller_test.rb b/test/controllers/games_controller_test.rb new file mode 100644 index 0000000..420758e --- /dev/null +++ b/test/controllers/games_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class GamesControllerTest < ActionController::TestCase + setup do + @game = games(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:games) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create game" do + assert_difference('Game.count') do + post :create, game: { name: @game.name } + end + + assert_redirected_to game_path(assigns(:game)) + end + + test "should show game" do + get :show, id: @game + assert_response :success + end + + test "should get edit" do + get :edit, id: @game + assert_response :success + end + + test "should update game" do + patch :update, id: @game, game: { name: @game.name } + assert_redirected_to game_path(assigns(:game)) + end + + test "should destroy game" do + assert_difference('Game.count', -1) do + delete :destroy, id: @game + end + + assert_redirected_to games_path + end +end diff --git a/test/fixtures/game_attributes.yml b/test/fixtures/game_attributes.yml new file mode 100644 index 0000000..eff7212 --- /dev/null +++ b/test/fixtures/game_attributes.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + game_id: + key: MyText + type: 1 + +two: + game_id: + key: MyText + type: 1 diff --git a/test/fixtures/games.yml b/test/fixtures/games.yml new file mode 100644 index 0000000..ce6f466 --- /dev/null +++ b/test/fixtures/games.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyText + +two: + name: MyText diff --git a/test/helpers/games_helper_test.rb b/test/helpers/games_helper_test.rb new file mode 100644 index 0000000..449a85c --- /dev/null +++ b/test/helpers/games_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class GamesHelperTest < ActionView::TestCase +end diff --git a/test/models/game_attribute_test.rb b/test/models/game_attribute_test.rb new file mode 100644 index 0000000..13c6e65 --- /dev/null +++ b/test/models/game_attribute_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GameAttributeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/game_test.rb b/test/models/game_test.rb new file mode 100644 index 0000000..2cab36e --- /dev/null +++ b/test/models/game_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GameTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end -- cgit v1.2.3 From de40ec53e8b80d8d880214183f19ea93172a0026 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 27 Feb 2014 17:02:10 -0500 Subject: give tournaments a game type --- app/controllers/tournaments_controller.rb | 2 +- app/models/tournament.rb | 1 + app/views/tournaments/_form.html.erb | 4 ++++ app/views/tournaments/index.html.erb | 2 ++ app/views/tournaments/index.json.jbuilder | 2 +- app/views/tournaments/show.html.erb | 5 +++++ app/views/tournaments/show.json.jbuilder | 2 +- db/migrate/20140304015013_create_servers.rb | 8 -------- db/migrate/20140304015015_create_tournaments.rb | 8 -------- db/migrate/20140304015017_create_matches.rb | 9 --------- db/migrate/20140304015019_create_teams.rb | 8 -------- db/migrate/20140304015021_create_users.rb | 11 ----------- db/migrate/20140304015023_create_user_team_pairs.rb | 10 ---------- db/migrate/20140304015026_create_team_match_pairs.rb | 10 ---------- db/migrate/20140304015028_create_alerts.rb | 10 ---------- db/migrate/20140304015030_create_pms.rb | 11 ----------- db/migrate/20140304015032_create_games.rb | 9 --------- db/migrate/20140304015034_create_game_attributes.rb | 11 ----------- db/migrate/20140304015036_create_server_settings.rb | 8 -------- db/migrate/20140304015042_create_tournament_options.rb | 8 -------- db/migrate/20140304015051_create_servers.rb | 8 ++++++++ db/migrate/20140304015053_create_tournaments.rb | 9 +++++++++ db/migrate/20140304015055_create_matches.rb | 9 +++++++++ db/migrate/20140304015057_create_teams.rb | 8 ++++++++ db/migrate/20140304015059_create_users.rb | 11 +++++++++++ db/migrate/20140304015102_create_user_team_pairs.rb | 10 ++++++++++ db/migrate/20140304015104_create_team_match_pairs.rb | 10 ++++++++++ db/migrate/20140304015106_create_alerts.rb | 10 ++++++++++ db/migrate/20140304015108_create_pms.rb | 11 +++++++++++ db/migrate/20140304015110_create_games.rb | 9 +++++++++ db/migrate/20140304015112_create_game_attributes.rb | 11 +++++++++++ db/migrate/20140304015114_create_server_settings.rb | 8 ++++++++ db/migrate/20140304015120_create_tournament_options.rb | 8 ++++++++ db/schema.rb | 5 ++++- generate.sh | 2 +- test/controllers/tournaments_controller_test.rb | 4 ++-- test/fixtures/tournaments.yml | 14 +++++--------- 37 files changed, 149 insertions(+), 137 deletions(-) delete mode 100644 db/migrate/20140304015013_create_servers.rb delete mode 100644 db/migrate/20140304015015_create_tournaments.rb delete mode 100644 db/migrate/20140304015017_create_matches.rb delete mode 100644 db/migrate/20140304015019_create_teams.rb delete mode 100644 db/migrate/20140304015021_create_users.rb delete mode 100644 db/migrate/20140304015023_create_user_team_pairs.rb delete mode 100644 db/migrate/20140304015026_create_team_match_pairs.rb delete mode 100644 db/migrate/20140304015028_create_alerts.rb delete mode 100644 db/migrate/20140304015030_create_pms.rb delete mode 100644 db/migrate/20140304015032_create_games.rb delete mode 100644 db/migrate/20140304015034_create_game_attributes.rb delete mode 100644 db/migrate/20140304015036_create_server_settings.rb delete mode 100644 db/migrate/20140304015042_create_tournament_options.rb create mode 100644 db/migrate/20140304015051_create_servers.rb create mode 100644 db/migrate/20140304015053_create_tournaments.rb create mode 100644 db/migrate/20140304015055_create_matches.rb create mode 100644 db/migrate/20140304015057_create_teams.rb create mode 100644 db/migrate/20140304015059_create_users.rb create mode 100644 db/migrate/20140304015102_create_user_team_pairs.rb create mode 100644 db/migrate/20140304015104_create_team_match_pairs.rb create mode 100644 db/migrate/20140304015106_create_alerts.rb create mode 100644 db/migrate/20140304015108_create_pms.rb create mode 100644 db/migrate/20140304015110_create_games.rb create mode 100644 db/migrate/20140304015112_create_game_attributes.rb create mode 100644 db/migrate/20140304015114_create_server_settings.rb create mode 100644 db/migrate/20140304015120_create_tournament_options.rb diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index ea3857c..720305f 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -69,6 +69,6 @@ class TournamentsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def tournament_params - params[:tournament] + params.require(:tournament).permit(:game_id) end end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index da3da0e..cc915a0 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,2 +1,3 @@ class Tournament < ActiveRecord::Base + belongs_to :game end diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 8996266..1fd63e9 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -11,6 +11,10 @@ <% end %> +
+ <%= f.label :game_id %>
+ <%= f.text_field :game_id %> +
<%= f.submit %>
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 7124111..ad2b7cf 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -3,6 +3,7 @@ + @@ -12,6 +13,7 @@ <% @tournaments.each do |tournament| %> + diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder index 28d6960..e6f3b49 100644 --- a/app/views/tournaments/index.json.jbuilder +++ b/app/views/tournaments/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@tournaments) do |tournament| - json.extract! tournament, :id + json.extract! tournament, :id, :game_id json.url tournament_url(tournament, format: :json) end diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 2c280ba..30df788 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,4 +1,9 @@

<%= notice %>

+

+ Game: + <%= @tournament.game %> +

+ <%= link_to 'Edit', edit_tournament_path(@tournament) %> | <%= link_to 'Back', tournaments_path %> diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder index 211799a..0fe65a6 100644 --- a/app/views/tournaments/show.json.jbuilder +++ b/app/views/tournaments/show.json.jbuilder @@ -1 +1 @@ -json.extract! @tournament, :id, :created_at, :updated_at +json.extract! @tournament, :id, :game_id, :created_at, :updated_at diff --git a/db/migrate/20140304015013_create_servers.rb b/db/migrate/20140304015013_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140304015013_create_servers.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015015_create_tournaments.rb b/db/migrate/20140304015015_create_tournaments.rb deleted file mode 100644 index 2095590..0000000 --- a/db/migrate/20140304015015_create_tournaments.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015017_create_matches.rb b/db/migrate/20140304015017_create_matches.rb deleted file mode 100644 index 6c0c157..0000000 --- a/db/migrate/20140304015017_create_matches.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015019_create_teams.rb b/db/migrate/20140304015019_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140304015019_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015021_create_users.rb b/db/migrate/20140304015021_create_users.rb deleted file mode 100644 index 6a500e5..0000000 --- a/db/migrate/20140304015021_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.text :name - t.text :pw_hash - t.integer :groups - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015023_create_user_team_pairs.rb b/db/migrate/20140304015023_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140304015023_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015026_create_team_match_pairs.rb b/db/migrate/20140304015026_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140304015026_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015028_create_alerts.rb b/db/migrate/20140304015028_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140304015028_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015030_create_pms.rb b/db/migrate/20140304015030_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140304015030_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015032_create_games.rb b/db/migrate/20140304015032_create_games.rb deleted file mode 100644 index fc54709..0000000 --- a/db/migrate/20140304015032_create_games.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateGames < ActiveRecord::Migration - def change - create_table :games do |t| - t.text :name - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015034_create_game_attributes.rb b/db/migrate/20140304015034_create_game_attributes.rb deleted file mode 100644 index b63f134..0000000 --- a/db/migrate/20140304015034_create_game_attributes.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateGameAttributes < ActiveRecord::Migration - def change - create_table :game_attributes do |t| - t.references :game, index: true - t.text :key - t.integer :type - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015036_create_server_settings.rb b/db/migrate/20140304015036_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140304015036_create_server_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServerSettings < ActiveRecord::Migration - def change - create_table :server_settings do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015042_create_tournament_options.rb b/db/migrate/20140304015042_create_tournament_options.rb deleted file mode 100644 index d2df22e..0000000 --- a/db/migrate/20140304015042_create_tournament_options.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentOptions < ActiveRecord::Migration - def change - create_table :tournament_options do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015051_create_servers.rb b/db/migrate/20140304015051_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140304015051_create_servers.rb @@ -0,0 +1,8 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015053_create_tournaments.rb b/db/migrate/20140304015053_create_tournaments.rb new file mode 100644 index 0000000..36fcf7e --- /dev/null +++ b/db/migrate/20140304015053_create_tournaments.rb @@ -0,0 +1,9 @@ +class CreateTournaments < ActiveRecord::Migration + def change + create_table :tournaments do |t| + t.references :game, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015055_create_matches.rb b/db/migrate/20140304015055_create_matches.rb new file mode 100644 index 0000000..6c0c157 --- /dev/null +++ b/db/migrate/20140304015055_create_matches.rb @@ -0,0 +1,9 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015057_create_teams.rb b/db/migrate/20140304015057_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140304015057_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015059_create_users.rb b/db/migrate/20140304015059_create_users.rb new file mode 100644 index 0000000..6a500e5 --- /dev/null +++ b/db/migrate/20140304015059_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.text :name + t.text :pw_hash + t.integer :groups + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015102_create_user_team_pairs.rb b/db/migrate/20140304015102_create_user_team_pairs.rb new file mode 100644 index 0000000..2c492ac --- /dev/null +++ b/db/migrate/20140304015102_create_user_team_pairs.rb @@ -0,0 +1,10 @@ +class CreateUserTeamPairs < ActiveRecord::Migration + def change + create_table :user_team_pairs do |t| + t.references :user, index: true + t.references :team, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015104_create_team_match_pairs.rb b/db/migrate/20140304015104_create_team_match_pairs.rb new file mode 100644 index 0000000..8fac07e --- /dev/null +++ b/db/migrate/20140304015104_create_team_match_pairs.rb @@ -0,0 +1,10 @@ +class CreateTeamMatchPairs < ActiveRecord::Migration + def change + create_table :team_match_pairs do |t| + t.references :team, index: true + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015106_create_alerts.rb b/db/migrate/20140304015106_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140304015106_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015108_create_pms.rb b/db/migrate/20140304015108_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140304015108_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015110_create_games.rb b/db/migrate/20140304015110_create_games.rb new file mode 100644 index 0000000..fc54709 --- /dev/null +++ b/db/migrate/20140304015110_create_games.rb @@ -0,0 +1,9 @@ +class CreateGames < ActiveRecord::Migration + def change + create_table :games do |t| + t.text :name + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015112_create_game_attributes.rb b/db/migrate/20140304015112_create_game_attributes.rb new file mode 100644 index 0000000..b63f134 --- /dev/null +++ b/db/migrate/20140304015112_create_game_attributes.rb @@ -0,0 +1,11 @@ +class CreateGameAttributes < ActiveRecord::Migration + def change + create_table :game_attributes do |t| + t.references :game, index: true + t.text :key + t.integer :type + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015114_create_server_settings.rb b/db/migrate/20140304015114_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140304015114_create_server_settings.rb @@ -0,0 +1,8 @@ +class CreateServerSettings < ActiveRecord::Migration + def change + create_table :server_settings do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015120_create_tournament_options.rb b/db/migrate/20140304015120_create_tournament_options.rb new file mode 100644 index 0000000..d2df22e --- /dev/null +++ b/db/migrate/20140304015120_create_tournament_options.rb @@ -0,0 +1,8 @@ +class CreateTournamentOptions < ActiveRecord::Migration + def change + create_table :tournament_options do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 86afd1b..7681cfc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140304015042) do +ActiveRecord::Schema.define(version: 20140304015120) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -88,10 +88,13 @@ ActiveRecord::Schema.define(version: 20140304015042) do end create_table "tournaments", force: true do |t| + t.integer "game_id" t.datetime "created_at" t.datetime "updated_at" end + add_index "tournaments", ["game_id"], name: "index_tournaments_on_game_id" + create_table "user_team_pairs", force: true do |t| t.integer "user_id" t.integer "team_id" diff --git a/generate.sh b/generate.sh index 7dbb444..b384813 100755 --- a/generate.sh +++ b/generate.sh @@ -10,7 +10,7 @@ set -x bundle exec rails generate scaffold server -bundle exec rails generate scaffold tournament +bundle exec rails generate scaffold tournament game:references bundle exec rails generate scaffold match tournament:references bundle exec rails generate scaffold team bundle exec rails generate scaffold user name:text pw_hash:text groups:integer diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb index 9363bdf..bdbbfac 100644 --- a/test/controllers/tournaments_controller_test.rb +++ b/test/controllers/tournaments_controller_test.rb @@ -18,7 +18,7 @@ class TournamentsControllerTest < ActionController::TestCase test "should create tournament" do assert_difference('Tournament.count') do - post :create, tournament: { } + post :create, tournament: { game_id: @tournament.game_id } end assert_redirected_to tournament_path(assigns(:tournament)) @@ -35,7 +35,7 @@ class TournamentsControllerTest < ActionController::TestCase end test "should update tournament" do - patch :update, id: @tournament, tournament: { } + patch :update, id: @tournament, tournament: { game_id: @tournament.game_id } assert_redirected_to tournament_path(assigns(:tournament)) end diff --git a/test/fixtures/tournaments.yml b/test/fixtures/tournaments.yml index 937a0c0..4cba7ca 100644 --- a/test/fixtures/tournaments.yml +++ b/test/fixtures/tournaments.yml @@ -1,11 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value +one: + game_id: + +two: + game_id: -- cgit v1.2.3 From f3f17dcd9755020276062caae7c0677eff88cb2f Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 27 Feb 2014 17:41:59 -0500 Subject: Added the Games Attributes stuff. --- app/controllers/games_controller.rb | 2 +- app/views/games/_form.html.erb | 16 ++++++++++++++++ app/views/games/index.html.erb | 8 ++++++++ app/views/games/index.json.jbuilder | 2 +- app/views/games/show.html.erb | 20 ++++++++++++++++++++ app/views/games/show.json.jbuilder | 2 +- db/migrate/20140304015051_create_servers.rb | 8 -------- db/migrate/20140304015053_create_tournaments.rb | 9 --------- db/migrate/20140304015055_create_matches.rb | 9 --------- db/migrate/20140304015057_create_teams.rb | 8 -------- db/migrate/20140304015059_create_users.rb | 11 ----------- db/migrate/20140304015102_create_user_team_pairs.rb | 10 ---------- db/migrate/20140304015104_create_team_match_pairs.rb | 10 ---------- db/migrate/20140304015106_create_alerts.rb | 10 ---------- db/migrate/20140304015108_create_pms.rb | 11 ----------- db/migrate/20140304015110_create_games.rb | 9 --------- db/migrate/20140304015112_create_game_attributes.rb | 11 ----------- db/migrate/20140304015114_create_server_settings.rb | 8 -------- .../20140304015120_create_tournament_options.rb | 8 -------- db/migrate/20140304015129_create_servers.rb | 8 ++++++++ db/migrate/20140304015131_create_tournaments.rb | 9 +++++++++ db/migrate/20140304015133_create_matches.rb | 9 +++++++++ db/migrate/20140304015135_create_teams.rb | 8 ++++++++ db/migrate/20140304015137_create_users.rb | 11 +++++++++++ db/migrate/20140304015139_create_user_team_pairs.rb | 10 ++++++++++ db/migrate/20140304015141_create_team_match_pairs.rb | 10 ++++++++++ db/migrate/20140304015144_create_alerts.rb | 10 ++++++++++ db/migrate/20140304015146_create_pms.rb | 11 +++++++++++ db/migrate/20140304015148_create_games.rb | 13 +++++++++++++ db/migrate/20140304015150_create_game_attributes.rb | 11 +++++++++++ db/migrate/20140304015152_create_server_settings.rb | 8 ++++++++ .../20140304015158_create_tournament_options.rb | 8 ++++++++ db/schema.rb | 6 +++++- generate.sh | 2 +- test/controllers/games_controller_test.rb | 4 ++-- test/fixtures/games.yml | 8 ++++++++ 36 files changed, 189 insertions(+), 129 deletions(-) delete mode 100644 db/migrate/20140304015051_create_servers.rb delete mode 100644 db/migrate/20140304015053_create_tournaments.rb delete mode 100644 db/migrate/20140304015055_create_matches.rb delete mode 100644 db/migrate/20140304015057_create_teams.rb delete mode 100644 db/migrate/20140304015059_create_users.rb delete mode 100644 db/migrate/20140304015102_create_user_team_pairs.rb delete mode 100644 db/migrate/20140304015104_create_team_match_pairs.rb delete mode 100644 db/migrate/20140304015106_create_alerts.rb delete mode 100644 db/migrate/20140304015108_create_pms.rb delete mode 100644 db/migrate/20140304015110_create_games.rb delete mode 100644 db/migrate/20140304015112_create_game_attributes.rb delete mode 100644 db/migrate/20140304015114_create_server_settings.rb delete mode 100644 db/migrate/20140304015120_create_tournament_options.rb create mode 100644 db/migrate/20140304015129_create_servers.rb create mode 100644 db/migrate/20140304015131_create_tournaments.rb create mode 100644 db/migrate/20140304015133_create_matches.rb create mode 100644 db/migrate/20140304015135_create_teams.rb create mode 100644 db/migrate/20140304015137_create_users.rb create mode 100644 db/migrate/20140304015139_create_user_team_pairs.rb create mode 100644 db/migrate/20140304015141_create_team_match_pairs.rb create mode 100644 db/migrate/20140304015144_create_alerts.rb create mode 100644 db/migrate/20140304015146_create_pms.rb create mode 100644 db/migrate/20140304015148_create_games.rb create mode 100644 db/migrate/20140304015150_create_game_attributes.rb create mode 100644 db/migrate/20140304015152_create_server_settings.rb create mode 100644 db/migrate/20140304015158_create_tournament_options.rb diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 0a9d8e8..4ecff17 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -69,6 +69,6 @@ class GamesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def game_params - params.require(:game).permit(:name) + params.require(:game).permit(:name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams) end end diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb index 0bbdd1f..8941c59 100644 --- a/app/views/games/_form.html.erb +++ b/app/views/games/_form.html.erb @@ -15,6 +15,22 @@ <%= f.label :name %>
<%= f.text_area :name %> +
+ <%= f.label :players_per_team %>
+ <%= f.number_field :players_per_team %> +
+
+ <%= f.label :teams_per_match %>
+ <%= f.number_field :teams_per_match %> +
+
+ <%= f.label :set_rounds %>
+ <%= f.number_field :set_rounds %> +
+
+ <%= f.label :randomized_teams %>
+ <%= f.number_field :randomized_teams %> +
<%= f.submit %>
diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index 27d47b6..ccd0f63 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -4,6 +4,10 @@
+ + + + @@ -14,6 +18,10 @@ <% @games.each do |game| %> + + + + diff --git a/app/views/games/index.json.jbuilder b/app/views/games/index.json.jbuilder index 90f4236..7e5c1a1 100644 --- a/app/views/games/index.json.jbuilder +++ b/app/views/games/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@games) do |game| - json.extract! game, :id, :name + json.extract! game, :id, :name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams json.url game_url(game, format: :json) end diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 20d374f..7986016 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -5,5 +5,25 @@ <%= @game.name %>

+

+ Players per team: + <%= @game.players_per_team %> +

+ +

+ Teams per match: + <%= @game.teams_per_match %> +

+ +

+ Set rounds: + <%= @game.set_rounds %> +

+ +

+ Randomized teams: + <%= @game.randomized_teams %> +

+ <%= link_to 'Edit', edit_game_path(@game) %> | <%= link_to 'Back', games_path %> diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index a4d8d1c..1a2d0c7 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -1 +1 @@ -json.extract! @game, :id, :name, :created_at, :updated_at +json.extract! @game, :id, :name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at diff --git a/db/migrate/20140304015051_create_servers.rb b/db/migrate/20140304015051_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140304015051_create_servers.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015053_create_tournaments.rb b/db/migrate/20140304015053_create_tournaments.rb deleted file mode 100644 index 36fcf7e..0000000 --- a/db/migrate/20140304015053_create_tournaments.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - t.references :game, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015055_create_matches.rb b/db/migrate/20140304015055_create_matches.rb deleted file mode 100644 index 6c0c157..0000000 --- a/db/migrate/20140304015055_create_matches.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015057_create_teams.rb b/db/migrate/20140304015057_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140304015057_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015059_create_users.rb b/db/migrate/20140304015059_create_users.rb deleted file mode 100644 index 6a500e5..0000000 --- a/db/migrate/20140304015059_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.text :name - t.text :pw_hash - t.integer :groups - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015102_create_user_team_pairs.rb b/db/migrate/20140304015102_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140304015102_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015104_create_team_match_pairs.rb b/db/migrate/20140304015104_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140304015104_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015106_create_alerts.rb b/db/migrate/20140304015106_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140304015106_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015108_create_pms.rb b/db/migrate/20140304015108_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140304015108_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015110_create_games.rb b/db/migrate/20140304015110_create_games.rb deleted file mode 100644 index fc54709..0000000 --- a/db/migrate/20140304015110_create_games.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateGames < ActiveRecord::Migration - def change - create_table :games do |t| - t.text :name - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015112_create_game_attributes.rb b/db/migrate/20140304015112_create_game_attributes.rb deleted file mode 100644 index b63f134..0000000 --- a/db/migrate/20140304015112_create_game_attributes.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateGameAttributes < ActiveRecord::Migration - def change - create_table :game_attributes do |t| - t.references :game, index: true - t.text :key - t.integer :type - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015114_create_server_settings.rb b/db/migrate/20140304015114_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140304015114_create_server_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServerSettings < ActiveRecord::Migration - def change - create_table :server_settings do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015120_create_tournament_options.rb b/db/migrate/20140304015120_create_tournament_options.rb deleted file mode 100644 index d2df22e..0000000 --- a/db/migrate/20140304015120_create_tournament_options.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentOptions < ActiveRecord::Migration - def change - create_table :tournament_options do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015129_create_servers.rb b/db/migrate/20140304015129_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140304015129_create_servers.rb @@ -0,0 +1,8 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015131_create_tournaments.rb b/db/migrate/20140304015131_create_tournaments.rb new file mode 100644 index 0000000..36fcf7e --- /dev/null +++ b/db/migrate/20140304015131_create_tournaments.rb @@ -0,0 +1,9 @@ +class CreateTournaments < ActiveRecord::Migration + def change + create_table :tournaments do |t| + t.references :game, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015133_create_matches.rb b/db/migrate/20140304015133_create_matches.rb new file mode 100644 index 0000000..6c0c157 --- /dev/null +++ b/db/migrate/20140304015133_create_matches.rb @@ -0,0 +1,9 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015135_create_teams.rb b/db/migrate/20140304015135_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140304015135_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015137_create_users.rb b/db/migrate/20140304015137_create_users.rb new file mode 100644 index 0000000..6a500e5 --- /dev/null +++ b/db/migrate/20140304015137_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.text :name + t.text :pw_hash + t.integer :groups + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015139_create_user_team_pairs.rb b/db/migrate/20140304015139_create_user_team_pairs.rb new file mode 100644 index 0000000..2c492ac --- /dev/null +++ b/db/migrate/20140304015139_create_user_team_pairs.rb @@ -0,0 +1,10 @@ +class CreateUserTeamPairs < ActiveRecord::Migration + def change + create_table :user_team_pairs do |t| + t.references :user, index: true + t.references :team, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015141_create_team_match_pairs.rb b/db/migrate/20140304015141_create_team_match_pairs.rb new file mode 100644 index 0000000..8fac07e --- /dev/null +++ b/db/migrate/20140304015141_create_team_match_pairs.rb @@ -0,0 +1,10 @@ +class CreateTeamMatchPairs < ActiveRecord::Migration + def change + create_table :team_match_pairs do |t| + t.references :team, index: true + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015144_create_alerts.rb b/db/migrate/20140304015144_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140304015144_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015146_create_pms.rb b/db/migrate/20140304015146_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140304015146_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015148_create_games.rb b/db/migrate/20140304015148_create_games.rb new file mode 100644 index 0000000..59d4ef0 --- /dev/null +++ b/db/migrate/20140304015148_create_games.rb @@ -0,0 +1,13 @@ +class CreateGames < ActiveRecord::Migration + def change + create_table :games do |t| + t.text :name + t.integer :players_per_team + t.integer :teams_per_match + t.integer :set_rounds + t.integer :randomized_teams + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015150_create_game_attributes.rb b/db/migrate/20140304015150_create_game_attributes.rb new file mode 100644 index 0000000..b63f134 --- /dev/null +++ b/db/migrate/20140304015150_create_game_attributes.rb @@ -0,0 +1,11 @@ +class CreateGameAttributes < ActiveRecord::Migration + def change + create_table :game_attributes do |t| + t.references :game, index: true + t.text :key + t.integer :type + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015152_create_server_settings.rb b/db/migrate/20140304015152_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140304015152_create_server_settings.rb @@ -0,0 +1,8 @@ +class CreateServerSettings < ActiveRecord::Migration + def change + create_table :server_settings do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015158_create_tournament_options.rb b/db/migrate/20140304015158_create_tournament_options.rb new file mode 100644 index 0000000..d2df22e --- /dev/null +++ b/db/migrate/20140304015158_create_tournament_options.rb @@ -0,0 +1,8 @@ +class CreateTournamentOptions < ActiveRecord::Migration + def change + create_table :tournament_options do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 7681cfc..42417f4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140304015120) do +ActiveRecord::Schema.define(version: 20140304015158) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -34,6 +34,10 @@ ActiveRecord::Schema.define(version: 20140304015120) do create_table "games", force: true do |t| t.text "name" + t.integer "players_per_team" + t.integer "teams_per_match" + t.integer "set_rounds" + t.integer "randomized_teams" t.datetime "created_at" t.datetime "updated_at" end diff --git a/generate.sh b/generate.sh index b384813..77d6cb9 100755 --- a/generate.sh +++ b/generate.sh @@ -18,7 +18,7 @@ bundle exec rails generate model user_team_pair user:references team:references bundle exec rails generate model team_match_pair team:references match:references bundle exec rails generate scaffold alert author:references message:text bundle exec rails generate scaffold pm author:references recipient:references message:text -bundle exec rails generate scaffold game name:text +bundle exec rails generate scaffold game name:text players_per_team:integer teams_per_match:integer set_rounds:integer randomized_teams:integer bundle exec rails generate model game_attribute game:references key:text type:integer bundle exec rails generate model server_settings bundle exec rails generate controller search diff --git a/test/controllers/games_controller_test.rb b/test/controllers/games_controller_test.rb index 420758e..95c3145 100644 --- a/test/controllers/games_controller_test.rb +++ b/test/controllers/games_controller_test.rb @@ -18,7 +18,7 @@ class GamesControllerTest < ActionController::TestCase test "should create game" do assert_difference('Game.count') do - post :create, game: { name: @game.name } + post :create, game: { name: @game.name, players_per_team: @game.players_per_team, randomized_teams: @game.randomized_teams, set_rounds: @game.set_rounds, teams_per_match: @game.teams_per_match } end assert_redirected_to game_path(assigns(:game)) @@ -35,7 +35,7 @@ class GamesControllerTest < ActionController::TestCase end test "should update game" do - patch :update, id: @game, game: { name: @game.name } + patch :update, id: @game, game: { name: @game.name, players_per_team: @game.players_per_team, randomized_teams: @game.randomized_teams, set_rounds: @game.set_rounds, teams_per_match: @game.teams_per_match } assert_redirected_to game_path(assigns(:game)) end diff --git a/test/fixtures/games.yml b/test/fixtures/games.yml index ce6f466..3068527 100644 --- a/test/fixtures/games.yml +++ b/test/fixtures/games.yml @@ -2,6 +2,14 @@ one: name: MyText + players_per_team: 1 + teams_per_match: 1 + set_rounds: 1 + randomized_teams: 1 two: name: MyText + players_per_team: 1 + teams_per_match: 1 + set_rounds: 1 + randomized_teams: 1 -- cgit v1.2.3 From 068e95231c3d2cee113cf77af67ce785d853429e Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 27 Feb 2014 17:44:37 -0500 Subject: Added the seeding to generation. --- db/migrate/20140304015129_create_servers.rb | 8 -------- db/migrate/20140304015131_create_tournaments.rb | 9 --------- db/migrate/20140304015133_create_matches.rb | 9 --------- db/migrate/20140304015135_create_teams.rb | 8 -------- db/migrate/20140304015137_create_users.rb | 11 ----------- db/migrate/20140304015139_create_user_team_pairs.rb | 10 ---------- db/migrate/20140304015141_create_team_match_pairs.rb | 10 ---------- db/migrate/20140304015144_create_alerts.rb | 10 ---------- db/migrate/20140304015146_create_pms.rb | 11 ----------- db/migrate/20140304015148_create_games.rb | 13 ------------- db/migrate/20140304015150_create_game_attributes.rb | 11 ----------- db/migrate/20140304015152_create_server_settings.rb | 8 -------- db/migrate/20140304015158_create_tournament_options.rb | 8 -------- db/migrate/20140304015206_create_servers.rb | 8 ++++++++ db/migrate/20140304015209_create_tournaments.rb | 9 +++++++++ db/migrate/20140304015211_create_matches.rb | 9 +++++++++ db/migrate/20140304015213_create_teams.rb | 8 ++++++++ db/migrate/20140304015215_create_users.rb | 11 +++++++++++ db/migrate/20140304015217_create_user_team_pairs.rb | 10 ++++++++++ db/migrate/20140304015219_create_team_match_pairs.rb | 10 ++++++++++ db/migrate/20140304015221_create_alerts.rb | 10 ++++++++++ db/migrate/20140304015223_create_pms.rb | 11 +++++++++++ db/migrate/20140304015226_create_games.rb | 13 +++++++++++++ db/migrate/20140304015228_create_game_attributes.rb | 11 +++++++++++ db/migrate/20140304015230_create_server_settings.rb | 8 ++++++++ db/migrate/20140304015236_create_tournament_options.rb | 8 ++++++++ db/schema.rb | 2 +- generate.sh | 2 +- 28 files changed, 128 insertions(+), 128 deletions(-) delete mode 100644 db/migrate/20140304015129_create_servers.rb delete mode 100644 db/migrate/20140304015131_create_tournaments.rb delete mode 100644 db/migrate/20140304015133_create_matches.rb delete mode 100644 db/migrate/20140304015135_create_teams.rb delete mode 100644 db/migrate/20140304015137_create_users.rb delete mode 100644 db/migrate/20140304015139_create_user_team_pairs.rb delete mode 100644 db/migrate/20140304015141_create_team_match_pairs.rb delete mode 100644 db/migrate/20140304015144_create_alerts.rb delete mode 100644 db/migrate/20140304015146_create_pms.rb delete mode 100644 db/migrate/20140304015148_create_games.rb delete mode 100644 db/migrate/20140304015150_create_game_attributes.rb delete mode 100644 db/migrate/20140304015152_create_server_settings.rb delete mode 100644 db/migrate/20140304015158_create_tournament_options.rb create mode 100644 db/migrate/20140304015206_create_servers.rb create mode 100644 db/migrate/20140304015209_create_tournaments.rb create mode 100644 db/migrate/20140304015211_create_matches.rb create mode 100644 db/migrate/20140304015213_create_teams.rb create mode 100644 db/migrate/20140304015215_create_users.rb create mode 100644 db/migrate/20140304015217_create_user_team_pairs.rb create mode 100644 db/migrate/20140304015219_create_team_match_pairs.rb create mode 100644 db/migrate/20140304015221_create_alerts.rb create mode 100644 db/migrate/20140304015223_create_pms.rb create mode 100644 db/migrate/20140304015226_create_games.rb create mode 100644 db/migrate/20140304015228_create_game_attributes.rb create mode 100644 db/migrate/20140304015230_create_server_settings.rb create mode 100644 db/migrate/20140304015236_create_tournament_options.rb diff --git a/db/migrate/20140304015129_create_servers.rb b/db/migrate/20140304015129_create_servers.rb deleted file mode 100644 index f33241a..0000000 --- a/db/migrate/20140304015129_create_servers.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015131_create_tournaments.rb b/db/migrate/20140304015131_create_tournaments.rb deleted file mode 100644 index 36fcf7e..0000000 --- a/db/migrate/20140304015131_create_tournaments.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - t.references :game, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015133_create_matches.rb b/db/migrate/20140304015133_create_matches.rb deleted file mode 100644 index 6c0c157..0000000 --- a/db/migrate/20140304015133_create_matches.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015135_create_teams.rb b/db/migrate/20140304015135_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140304015135_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015137_create_users.rb b/db/migrate/20140304015137_create_users.rb deleted file mode 100644 index 6a500e5..0000000 --- a/db/migrate/20140304015137_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.text :name - t.text :pw_hash - t.integer :groups - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015139_create_user_team_pairs.rb b/db/migrate/20140304015139_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140304015139_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015141_create_team_match_pairs.rb b/db/migrate/20140304015141_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140304015141_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015144_create_alerts.rb b/db/migrate/20140304015144_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140304015144_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015146_create_pms.rb b/db/migrate/20140304015146_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140304015146_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015148_create_games.rb b/db/migrate/20140304015148_create_games.rb deleted file mode 100644 index 59d4ef0..0000000 --- a/db/migrate/20140304015148_create_games.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateGames < ActiveRecord::Migration - def change - create_table :games do |t| - t.text :name - t.integer :players_per_team - t.integer :teams_per_match - t.integer :set_rounds - t.integer :randomized_teams - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015150_create_game_attributes.rb b/db/migrate/20140304015150_create_game_attributes.rb deleted file mode 100644 index b63f134..0000000 --- a/db/migrate/20140304015150_create_game_attributes.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateGameAttributes < ActiveRecord::Migration - def change - create_table :game_attributes do |t| - t.references :game, index: true - t.text :key - t.integer :type - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015152_create_server_settings.rb b/db/migrate/20140304015152_create_server_settings.rb deleted file mode 100644 index dfdd91b..0000000 --- a/db/migrate/20140304015152_create_server_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateServerSettings < ActiveRecord::Migration - def change - create_table :server_settings do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015158_create_tournament_options.rb b/db/migrate/20140304015158_create_tournament_options.rb deleted file mode 100644 index d2df22e..0000000 --- a/db/migrate/20140304015158_create_tournament_options.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentOptions < ActiveRecord::Migration - def change - create_table :tournament_options do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140304015206_create_servers.rb b/db/migrate/20140304015206_create_servers.rb new file mode 100644 index 0000000..f33241a --- /dev/null +++ b/db/migrate/20140304015206_create_servers.rb @@ -0,0 +1,8 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015209_create_tournaments.rb b/db/migrate/20140304015209_create_tournaments.rb new file mode 100644 index 0000000..36fcf7e --- /dev/null +++ b/db/migrate/20140304015209_create_tournaments.rb @@ -0,0 +1,9 @@ +class CreateTournaments < ActiveRecord::Migration + def change + create_table :tournaments do |t| + t.references :game, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015211_create_matches.rb b/db/migrate/20140304015211_create_matches.rb new file mode 100644 index 0000000..6c0c157 --- /dev/null +++ b/db/migrate/20140304015211_create_matches.rb @@ -0,0 +1,9 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.references :tournament, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015213_create_teams.rb b/db/migrate/20140304015213_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140304015213_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015215_create_users.rb b/db/migrate/20140304015215_create_users.rb new file mode 100644 index 0000000..6a500e5 --- /dev/null +++ b/db/migrate/20140304015215_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.text :name + t.text :pw_hash + t.integer :groups + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015217_create_user_team_pairs.rb b/db/migrate/20140304015217_create_user_team_pairs.rb new file mode 100644 index 0000000..2c492ac --- /dev/null +++ b/db/migrate/20140304015217_create_user_team_pairs.rb @@ -0,0 +1,10 @@ +class CreateUserTeamPairs < ActiveRecord::Migration + def change + create_table :user_team_pairs do |t| + t.references :user, index: true + t.references :team, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015219_create_team_match_pairs.rb b/db/migrate/20140304015219_create_team_match_pairs.rb new file mode 100644 index 0000000..8fac07e --- /dev/null +++ b/db/migrate/20140304015219_create_team_match_pairs.rb @@ -0,0 +1,10 @@ +class CreateTeamMatchPairs < ActiveRecord::Migration + def change + create_table :team_match_pairs do |t| + t.references :team, index: true + t.references :match, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015221_create_alerts.rb b/db/migrate/20140304015221_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140304015221_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015223_create_pms.rb b/db/migrate/20140304015223_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140304015223_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015226_create_games.rb b/db/migrate/20140304015226_create_games.rb new file mode 100644 index 0000000..59d4ef0 --- /dev/null +++ b/db/migrate/20140304015226_create_games.rb @@ -0,0 +1,13 @@ +class CreateGames < ActiveRecord::Migration + def change + create_table :games do |t| + t.text :name + t.integer :players_per_team + t.integer :teams_per_match + t.integer :set_rounds + t.integer :randomized_teams + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015228_create_game_attributes.rb b/db/migrate/20140304015228_create_game_attributes.rb new file mode 100644 index 0000000..b63f134 --- /dev/null +++ b/db/migrate/20140304015228_create_game_attributes.rb @@ -0,0 +1,11 @@ +class CreateGameAttributes < ActiveRecord::Migration + def change + create_table :game_attributes do |t| + t.references :game, index: true + t.text :key + t.integer :type + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015230_create_server_settings.rb b/db/migrate/20140304015230_create_server_settings.rb new file mode 100644 index 0000000..dfdd91b --- /dev/null +++ b/db/migrate/20140304015230_create_server_settings.rb @@ -0,0 +1,8 @@ +class CreateServerSettings < ActiveRecord::Migration + def change + create_table :server_settings do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140304015236_create_tournament_options.rb b/db/migrate/20140304015236_create_tournament_options.rb new file mode 100644 index 0000000..d2df22e --- /dev/null +++ b/db/migrate/20140304015236_create_tournament_options.rb @@ -0,0 +1,8 @@ +class CreateTournamentOptions < ActiveRecord::Migration + def change + create_table :tournament_options do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 42417f4..ede0e8c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140304015158) do +ActiveRecord::Schema.define(version: 20140304015236) do create_table "alerts", force: true do |t| t.integer "author_id" diff --git a/generate.sh b/generate.sh index 77d6cb9..9c6a1ab 100755 --- a/generate.sh +++ b/generate.sh @@ -29,5 +29,5 @@ bundle exec rails generate model tournament_options bundle exec rake db:drop RAILS_ENV=development bundle exec rake db:migrate RAILS_ENV=development - +bundle exec rake db:seed #bundle exec rails generate scaffold -- cgit v1.2.3
Game
<%= tournament.game %> <%= link_to 'Show', tournament %> <%= link_to 'Edit', edit_tournament_path(tournament) %> <%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %>
NamePlayers per teamTeams per matchSet roundsRandomized teams
<%= game.name %><%= game.players_per_team %><%= game.teams_per_match %><%= game.set_rounds %><%= game.randomized_teams %> <%= link_to 'Show', game %> <%= link_to 'Edit', edit_game_path(game) %> <%= link_to 'Destroy', game, method: :delete, data: { confirm: 'Are you sure?' } %>