Skip to content

Commit

Permalink
Commit 09:
Browse files Browse the repository at this point in the history
Done

· Fixed a typo in migration 012_add_teams_to_tournaments
· Added teams form to tournaments#edit (not working, just showing)


Todo:

· Create custom action "add_teams" for tournamentscontrollers


git-svn-id: http://svn2.assembla.com/svn/fs/trunk/fpt@9 d4c3aac1-5b85-48de-b3bb-3a454bd87b0a
  • Loading branch information
lmarcucci committed Feb 1, 2008
1 parent 435d14b commit 6d66874
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/controllers/tournaments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def create

def edit
@tournament = Tournament.find(params[:id])
@teams = Team.find(:all)
end

def update
Expand All @@ -57,4 +58,7 @@ def destroy
redirect_to :action => 'index'
end

def add_teams
end

end
1 change: 1 addition & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ class WelcomeController < ApplicationController

def index
end

end
4 changes: 3 additions & 1 deletion app/views/tournaments/_add_teams.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3>Participating teams:</h3>
<h3>Teams:</h3>

<% for team in @teams %>
<p>
Expand All @@ -8,3 +8,5 @@
<%= team.short_name.titleize %>
</p>
<% end %>

<%= submit_tag "Just Do It", :class => 'submit' %><br />
7 changes: 7 additions & 0 deletions app/views/tournaments/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<%= render :partial => "form", :locals => { :f => f} %>
<% end %>

<% form_for( :tournament,
:url => tournament_path(@tournament),
:html => { :method => :post }) do |f| %>

<%= render :partial => "add_teams", :locals => { :f => f} %>
<% end %>

<br />

<%= link_to 'tournaments', tournaments_path %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
map.root :controller => "welcome"
# map.resources :tournaments, :has_many => :standings
# map.resources :standings, :has_many => :matches, :belongs_to => :tournaments

map.resources :tournaments do |tournament|
tournament.resources :standings do |standing|
standing.resources :matches
Expand Down
6 changes: 3 additions & 3 deletions db/migrate/012_add_teams_to_tournaments.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class AddTeamsToTournaments < ActiveRecord::Migration
def self.up
@apertura = Tournament.find('1016639365')
@teams = Teams.find(:all)
@teams = Team.find(:all)
@apertura.teams << @teams
@apertura.save!
end

def self.down
# @apertura = Tournament.find('1016639365')
# @apertura.teams.delete(:all)
@apertura = Tournament.find('1016639365')
@apertura.teams.delete
end
end
113 changes: 104 additions & 9 deletions db/migrate/dev_data/standings.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
fecha1a07:
name: fecha 1
name: fecha 01
scheduled_date: 2007-08-05
tournament: apertura07

fecha2a07:
name: fecha 2
name: fecha 02
scheduled_date: 2007-08-12
tournament: apertura07

fecha3a07:
name: fecha 3
name: fecha 03
scheduled_date: 2007-08-19
tournament: apertura07

fecha4a07:
name: fecha 4
name: fecha 04
scheduled_date: 2007-08-26
tournament: apertura07

fecha5a07:
name: fecha 5
name: fecha 05
scheduled_date: 2007-08-29
tournament: apertura07

fecha6a07:
name: fecha 6
name: fecha 06
scheduled_date: 2007-09-02
tournament: apertura07

fecha7a07:
name: fecha 7
name: fecha 07
scheduled_date: 2007-09-09
tournament: apertura07

fecha8a07:
name: fecha 8
name: fecha 08
scheduled_date: 2007-09-12
tournament: apertura07

fecha9a07:
name: fecha 9
name: fecha 09
scheduled_date: 2007-09-17
tournament: apertura07

Expand Down Expand Up @@ -92,3 +92,98 @@ fecha19a07:
name: fecha 19
scheduled_date: 2007-12-09
tournament: apertura07

fecha1c08:
name: fecha 01
scheduled_date: 2008-02-10
tournament: clausura08

fecha2c08:
name: fecha 02
scheduled_date: 2008-02-17
tournament: clausura08

fecha3c08:
name: fecha 03
scheduled_date: 2008-02-24
tournament: clausura08

fecha4c08:
name: fecha 04
scheduled_date: 2008-03-02
tournament: clausura08

fecha5c08:
name: fecha 05
scheduled_date: 2008-03-09
tournament: clausura08

fecha6c08:
name: fecha 06
scheduled_date: 2008-03-16
tournament: clausura08

fecha7c08:
name: fecha 07
scheduled_date: 2008-03-23
tournament: clausura08

fecha8c08:
name: fecha 08
scheduled_date: 2008-03-30
tournament: clausura08

fecha9c08:
name: fecha 09
scheduled_date: 2008-04-06
tournament: clausura08

fecha10c08:
name: fecha 10
scheduled_date: 2008-04-13
tournament: clausura08

fecha11c08:
name: fecha 11
scheduled_date: 2008-04-20
tournament: clausura08

fecha12c08:
name: fecha 12
scheduled_date: 2008-04-27
tournament: clausura08

fecha13c08:
name: fecha 13
scheduled_date: 2008-05-04
tournament: clausura08

fecha14c08:
name: fecha 14
scheduled_date: 2008-05-11
tournament: clausura08

fecha15c08:
name: fecha 15
scheduled_date: 2008-05-18
tournament: clausura08

fecha16c08:
name: fecha 16
scheduled_date: 2008-05-25
tournament: clausura08

fecha17c08:
name: fecha 17
scheduled_date: 2008-06-01
tournament: clausura08

fecha18c08:
name: fecha 18
scheduled_date: 2008-06-08
tournament: clausura08

fecha19c08:
name: fecha 19
scheduled_date: 2008-06-15
tournament: clausura08
10 changes: 9 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 6) do
ActiveRecord::Schema.define(:version => 12) do

create_table "matches", :force => true do |t|
t.integer "standing_id"
Expand Down Expand Up @@ -43,6 +43,14 @@
t.string "nickname_name"
end

create_table "teams_tournaments", :id => false, :force => true do |t|
t.integer "team_id"
t.integer "tournament_id"
end

add_index "teams_tournaments", ["team_id"], :name => "index_teams_tournaments_on_team_id"
add_index "teams_tournaments", ["tournament_id"], :name => "index_teams_tournaments_on_tournament_id"

create_table "tournaments", :force => true do |t|
t.integer "t_type"
t.date "season"
Expand Down

0 comments on commit 6d66874

Please sign in to comment.