diff options
author | DavisLWebb <davislwebb@ymail.com> | 2014-02-20 17:13:51 -0500 |
---|---|---|
committer | DavisLWebb <davislwebb@ymail.com> | 2014-02-20 17:13:51 -0500 |
commit | cd1fabe40ca4d290df33a2590f3a1f2072103972 (patch) | |
tree | 98afd236e1d14e892602304e739fc65d450a43fd | |
parent | c14d0327a631a4321464c7c1e250d75458e13f49 (diff) |
fix datatype names in generate.sh
39 files changed, 161 insertions, 61 deletions
diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb index e6158f4..873e9b7 100644 --- a/app/controllers/alerts_controller.rb +++ b/app/controllers/alerts_controller.rb @@ -69,6 +69,6 @@ class AlertsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def alert_params - params.require(:alert).permit(:author, :message) + params.require(:alert).permit(:author_id, :message) end end diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index bb2a67a..e9f3c5a 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -69,6 +69,6 @@ class MatchesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def match_params - params.require(:match).permit(:tournament) + params.require(:match).permit(:tournament_id) end end diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb index 6eb94f9..5dd0d69 100644 --- a/app/controllers/pms_controller.rb +++ b/app/controllers/pms_controller.rb @@ -69,6 +69,6 @@ class PmsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def pm_params - params.require(:pm).permit(:author, :recipient, :message) + params.require(:pm).permit(:author_id, :recipient_id, :message) end end diff --git a/app/models/alert.rb b/app/models/alert.rb index e61a702..343c269 100644 --- a/app/models/alert.rb +++ b/app/models/alert.rb @@ -1,2 +1,3 @@ class Alert < ActiveRecord::Base + belongs_to :author end diff --git a/app/models/match.rb b/app/models/match.rb index 0836114..533435a 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,2 +1,3 @@ class Match < ActiveRecord::Base + belongs_to :tournament end diff --git a/app/models/pm.rb b/app/models/pm.rb index 24d6eb4..ab5af3b 100644 --- a/app/models/pm.rb +++ b/app/models/pm.rb @@ -1,2 +1,4 @@ class Pm < ActiveRecord::Base + belongs_to :author + belongs_to :recipient end diff --git a/app/models/team_match_pair.rb b/app/models/team_match_pair.rb index 24a4e86..85f8eaa 100644 --- a/app/models/team_match_pair.rb +++ b/app/models/team_match_pair.rb @@ -1,2 +1,4 @@ class TeamMatchPair < ActiveRecord::Base + belongs_to :team + belongs_to :match end diff --git a/app/models/user_team_pair.rb b/app/models/user_team_pair.rb index 7694996..c55dc2e 100644 --- a/app/models/user_team_pair.rb +++ b/app/models/user_team_pair.rb @@ -1,2 +1,4 @@ class UserTeamPair < ActiveRecord::Base + belongs_to :user + belongs_to :team end diff --git a/app/views/alerts/_form.html.erb b/app/views/alerts/_form.html.erb index f0da996..b60eaf2 100644 --- a/app/views/alerts/_form.html.erb +++ b/app/views/alerts/_form.html.erb @@ -12,8 +12,8 @@ <% end %> <div class="field"> - <%= f.label :author %><br> - <%= f.text_field :author %> + <%= f.label :author_id %><br> + <%= f.text_field :author_id %> </div> <div class="field"> <%= f.label :message %><br> diff --git a/app/views/alerts/index.json.jbuilder b/app/views/alerts/index.json.jbuilder index 685157e..0911a5c 100644 --- a/app/views/alerts/index.json.jbuilder +++ b/app/views/alerts/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@alerts) do |alert| - json.extract! alert, :id, :author, :message + json.extract! alert, :id, :author_id, :message json.url alert_url(alert, format: :json) end diff --git a/app/views/alerts/show.json.jbuilder b/app/views/alerts/show.json.jbuilder index 83fe24a..95481eb 100644 --- a/app/views/alerts/show.json.jbuilder +++ b/app/views/alerts/show.json.jbuilder @@ -1 +1 @@ -json.extract! @alert, :id, :author, :message, :created_at, :updated_at +json.extract! @alert, :id, :author_id, :message, :created_at, :updated_at diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 7d0a371..34494c3 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -12,8 +12,8 @@ <% end %> <div class="field"> - <%= f.label :tournament %><br> - <%= f.text_field :tournament %> + <%= f.label :tournament_id %><br> + <%= f.text_field :tournament_id %> </div> <div class="actions"> <%= f.submit %> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 0839c83..c8ada7a 100644 --- a/app/views/matches/index.json.jbuilder +++ b/app/views/matches/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@matches) do |match| - json.extract! match, :id, :tournament + json.extract! match, :id, :tournament_id json.url match_url(match, format: :json) end diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index a381f65..2e45395 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament, :created_at, :updated_at +json.extract! @match, :id, :tournament_id, :created_at, :updated_at diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb index bbc6aee..480e308 100644 --- a/app/views/pms/_form.html.erb +++ b/app/views/pms/_form.html.erb @@ -12,12 +12,12 @@ <% end %> <div class="field"> - <%= f.label :author %><br> - <%= f.text_field :author %> + <%= f.label :author_id %><br> + <%= f.text_field :author_id %> </div> <div class="field"> - <%= f.label :recipient %><br> - <%= f.text_field :recipient %> + <%= f.label :recipient_id %><br> + <%= f.text_field :recipient_id %> </div> <div class="field"> <%= f.label :message %><br> diff --git a/app/views/pms/index.json.jbuilder b/app/views/pms/index.json.jbuilder index aebdc08..fcfca84 100644 --- a/app/views/pms/index.json.jbuilder +++ b/app/views/pms/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@pms) do |pm| - json.extract! pm, :id, :author, :recipient, :message + json.extract! pm, :id, :author_id, :recipient_id, :message json.url pm_url(pm, format: :json) end diff --git a/app/views/pms/show.json.jbuilder b/app/views/pms/show.json.jbuilder index 651e78f..94252e9 100644 --- a/app/views/pms/show.json.jbuilder +++ b/app/views/pms/show.json.jbuilder @@ -1 +1 @@ -json.extract! @pm, :id, :author, :recipient, :message, :created_at, :updated_at +json.extract! @pm, :id, :author_id, :recipient_id, :message, :created_at, :updated_at diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index a7ead1b..2d1ad24 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -17,11 +17,11 @@ </div> <div class="field"> <%= f.label :pw_hash %><br> - <%= f.text_field :pw_hash %> + <%= f.text_area :pw_hash %> </div> <div class="field"> <%= f.label :groups %><br> - <%= f.text_field :groups %> + <%= f.number_field :groups %> </div> <div class="actions"> <%= f.submit %> diff --git a/db/migrate/20140304014808_create_servers.rb b/db/migrate/20140304014838_create_servers.rb index f33241a..f33241a 100644 --- a/db/migrate/20140304014808_create_servers.rb +++ b/db/migrate/20140304014838_create_servers.rb diff --git a/db/migrate/20140304014810_create_tournaments.rb b/db/migrate/20140304014840_create_tournaments.rb index 2095590..2095590 100644 --- a/db/migrate/20140304014810_create_tournaments.rb +++ b/db/migrate/20140304014840_create_tournaments.rb diff --git a/db/migrate/20140304014812_create_matches.rb b/db/migrate/20140304014842_create_matches.rb index 288ce6a..6c0c157 100644 --- a/db/migrate/20140304014812_create_matches.rb +++ b/db/migrate/20140304014842_create_matches.rb @@ -1,7 +1,7 @@ class CreateMatches < ActiveRecord::Migration def change create_table :matches do |t| - t.reference :tournament + t.references :tournament, index: true t.timestamps end diff --git a/db/migrate/20140304014814_create_teams.rb b/db/migrate/20140304014844_create_teams.rb index dd8397d..dd8397d 100644 --- a/db/migrate/20140304014814_create_teams.rb +++ b/db/migrate/20140304014844_create_teams.rb diff --git a/db/migrate/20140304014816_create_users.rb b/db/migrate/20140304014846_create_users.rb index 3723908..6a500e5 100644 --- a/db/migrate/20140304014816_create_users.rb +++ b/db/migrate/20140304014846_create_users.rb @@ -2,8 +2,8 @@ class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.text :name - t.varchar :pw_hash - t.int :groups + t.text :pw_hash + t.integer :groups t.timestamps end diff --git a/db/migrate/20140304014819_create_user_team_pairs.rb b/db/migrate/20140304014848_create_user_team_pairs.rb index 3b60212..2c492ac 100644 --- a/db/migrate/20140304014819_create_user_team_pairs.rb +++ b/db/migrate/20140304014848_create_user_team_pairs.rb @@ -1,8 +1,8 @@ class CreateUserTeamPairs < ActiveRecord::Migration def change create_table :user_team_pairs do |t| - t.reference :user - t.reference :team + t.references :user, index: true + t.references :team, index: true t.timestamps end diff --git a/db/migrate/20140304014821_create_team_match_pairs.rb b/db/migrate/20140304014850_create_team_match_pairs.rb index c489495..8fac07e 100644 --- a/db/migrate/20140304014821_create_team_match_pairs.rb +++ b/db/migrate/20140304014850_create_team_match_pairs.rb @@ -1,8 +1,8 @@ class CreateTeamMatchPairs < ActiveRecord::Migration def change create_table :team_match_pairs do |t| - t.reference :team - t.reference :match + t.references :team, index: true + t.references :match, index: true t.timestamps end diff --git a/db/migrate/20140304014823_create_alerts.rb b/db/migrate/20140304014852_create_alerts.rb index 6167f33..68a8e10 100644 --- a/db/migrate/20140304014823_create_alerts.rb +++ b/db/migrate/20140304014852_create_alerts.rb @@ -1,7 +1,7 @@ class CreateAlerts < ActiveRecord::Migration def change create_table :alerts do |t| - t.reference :author + t.references :author, index: true t.text :message t.timestamps diff --git a/db/migrate/20140304014825_create_pms.rb b/db/migrate/20140304014855_create_pms.rb index f3b27fb..93bb5c6 100644 --- a/db/migrate/20140304014825_create_pms.rb +++ b/db/migrate/20140304014855_create_pms.rb @@ -1,8 +1,8 @@ class CreatePms < ActiveRecord::Migration def change create_table :pms do |t| - t.reference :author - t.reference :recipient + t.references :author, index: true + t.references :recipient, index: true t.text :message t.timestamps diff --git a/db/migrate/20140304014827_create_server_settings.rb b/db/migrate/20140304014857_create_server_settings.rb index dfdd91b..dfdd91b 100644 --- a/db/migrate/20140304014827_create_server_settings.rb +++ b/db/migrate/20140304014857_create_server_settings.rb diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..88dfa1a --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,92 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20140304014857) do + + create_table "alerts", force: true do |t| + t.integer "author_id" + t.text "message" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "alerts", ["author_id"], name: "index_alerts_on_author_id" + + create_table "matches", force: true do |t| + t.integer "tournament_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id" + + create_table "pms", force: true do |t| + t.integer "author_id" + t.integer "recipient_id" + t.text "message" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "pms", ["author_id"], name: "index_pms_on_author_id" + add_index "pms", ["recipient_id"], name: "index_pms_on_recipient_id" + + create_table "server_settings", force: true do |t| + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "servers", force: true do |t| + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "team_match_pairs", force: true do |t| + t.integer "team_id" + t.integer "match_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "team_match_pairs", ["match_id"], name: "index_team_match_pairs_on_match_id" + add_index "team_match_pairs", ["team_id"], name: "index_team_match_pairs_on_team_id" + + create_table "teams", 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" + end + + create_table "user_team_pairs", force: true do |t| + t.integer "user_id" + t.integer "team_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "user_team_pairs", ["team_id"], name: "index_user_team_pairs_on_team_id" + add_index "user_team_pairs", ["user_id"], name: "index_user_team_pairs_on_user_id" + + create_table "users", force: true do |t| + t.text "name" + t.text "pw_hash" + t.integer "groups" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/generate.sh b/generate.sh index 28d1936..666869c 100755 --- a/generate.sh +++ b/generate.sh @@ -10,13 +10,13 @@ set -x bundle exec rails generate scaffold server bundle exec rails generate scaffold tournament -bundle exec rails generate scaffold match tournament:reference +bundle exec rails generate scaffold match tournament:references bundle exec rails generate scaffold team -bundle exec rails generate scaffold user name:text pw_hash:varchar groups:int -bundle exec rails generate model user_team_pair user:reference team:reference -bundle exec rails generate model team_match_pair team:reference match:reference -bundle exec rails generate scaffold alert author:reference message:text -bundle exec rails generate scaffold pm author:reference recipient:reference message:text +bundle exec rails generate scaffold user name:text pw_hash:text groups:integer +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 model server_settings bundle exec rails generate controller search bundle exec rails generate controller main diff --git a/test/controllers/alerts_controller_test.rb b/test/controllers/alerts_controller_test.rb index 29e58e9..4a5d911 100644 --- a/test/controllers/alerts_controller_test.rb +++ b/test/controllers/alerts_controller_test.rb @@ -18,7 +18,7 @@ class AlertsControllerTest < ActionController::TestCase test "should create alert" do assert_difference('Alert.count') do - post :create, alert: { author: @alert.author, message: @alert.message } + post :create, alert: { author_id: @alert.author_id, message: @alert.message } end assert_redirected_to alert_path(assigns(:alert)) @@ -35,7 +35,7 @@ class AlertsControllerTest < ActionController::TestCase end test "should update alert" do - patch :update, id: @alert, alert: { author: @alert.author, message: @alert.message } + patch :update, id: @alert, alert: { author_id: @alert.author_id, message: @alert.message } assert_redirected_to alert_path(assigns(:alert)) end diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb index 629622b..75c9dcf 100644 --- a/test/controllers/matches_controller_test.rb +++ b/test/controllers/matches_controller_test.rb @@ -18,7 +18,7 @@ class MatchesControllerTest < ActionController::TestCase test "should create match" do assert_difference('Match.count') do - post :create, match: { tournament: @match.tournament } + post :create, match: { tournament_id: @match.tournament_id } end assert_redirected_to match_path(assigns(:match)) @@ -35,7 +35,7 @@ class MatchesControllerTest < ActionController::TestCase end test "should update match" do - patch :update, id: @match, match: { tournament: @match.tournament } + patch :update, id: @match, match: { tournament_id: @match.tournament_id } assert_redirected_to match_path(assigns(:match)) end diff --git a/test/controllers/pms_controller_test.rb b/test/controllers/pms_controller_test.rb index ccbe7b1..18b2449 100644 --- a/test/controllers/pms_controller_test.rb +++ b/test/controllers/pms_controller_test.rb @@ -18,7 +18,7 @@ class PmsControllerTest < ActionController::TestCase test "should create pm" do assert_difference('Pm.count') do - post :create, pm: { author: @pm.author, message: @pm.message, recipient: @pm.recipient } + post :create, pm: { author_id: @pm.author_id, message: @pm.message, recipient_id: @pm.recipient_id } end assert_redirected_to pm_path(assigns(:pm)) @@ -35,7 +35,7 @@ class PmsControllerTest < ActionController::TestCase end test "should update pm" do - patch :update, id: @pm, pm: { author: @pm.author, message: @pm.message, recipient: @pm.recipient } + patch :update, id: @pm, pm: { author_id: @pm.author_id, message: @pm.message, recipient_id: @pm.recipient_id } assert_redirected_to pm_path(assigns(:pm)) end diff --git a/test/fixtures/alerts.yml b/test/fixtures/alerts.yml index 92ee1b0..52959af 100644 --- a/test/fixtures/alerts.yml +++ b/test/fixtures/alerts.yml @@ -1,9 +1,9 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: - author: + author_id: message: MyText two: - author: + author_id: message: MyText diff --git a/test/fixtures/matches.yml b/test/fixtures/matches.yml index 48c08a5..0356cee 100644 --- a/test/fixtures/matches.yml +++ b/test/fixtures/matches.yml @@ -1,7 +1,7 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: - tournament: + tournament_id: two: - tournament: + tournament_id: diff --git a/test/fixtures/pms.yml b/test/fixtures/pms.yml index 4ad9af3..f77e727 100644 --- a/test/fixtures/pms.yml +++ b/test/fixtures/pms.yml @@ -1,11 +1,11 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: - author: - recipient: + author_id: + recipient_id: message: MyText two: - author: - recipient: + author_id: + recipient_id: message: MyText diff --git a/test/fixtures/team_match_pairs.yml b/test/fixtures/team_match_pairs.yml index 1a81ab4..5f9cf2f 100644 --- a/test/fixtures/team_match_pairs.yml +++ b/test/fixtures/team_match_pairs.yml @@ -1,9 +1,9 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: - team: - match: + team_id: + match_id: two: - team: - match: + team_id: + match_id: diff --git a/test/fixtures/user_team_pairs.yml b/test/fixtures/user_team_pairs.yml index bda8bd3..a76036f 100644 --- a/test/fixtures/user_team_pairs.yml +++ b/test/fixtures/user_team_pairs.yml @@ -1,9 +1,9 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: - user: - team: + user_id: + team_id: two: - user: - team: + user_id: + team_id: diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 02ffdbb..9f593bc 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -2,10 +2,10 @@ one: name: MyText - pw_hash: - groups: + pw_hash: MyText + groups: 1 two: name: MyText - pw_hash: - groups: + pw_hash: MyText + groups: 1 |