Hi,

I am in the process of building a league management app.

I currently have seasons, leagues and teams that are all working fine. I
can create a new season, add the leagues that are playing in it and the
teams that play within each of the leagues.

What I now want to do is create fixtures for the teams. I have generated
a fixtures model and associated it with teams (has_many :teams) and
teams with fixtures (has_many :fixtures).

What I would like to be able to do when a user sets up the fixtures he
can just press a submit button that will generate all of the fixtures
between the teams (each team plays the other twice). I have been able,
using .permutations (get_team_combinations =
Team.names.permutation(2).to_a) to generate an array of fixtures but I
am stumped as
to how it would be possible to have each of these entries in the array
saved as a fixture in the database.

Anybody got any ideas how this is possible or an alternative way of
generating the fixtures?

Thanks for help in advance! :)

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Frederick Cheung at Oct 24, 2011 at 4:27 pm

    On Oct 24, 12:28 pm, Graham Dawe wrote:
    Hi,

    I am in the process of building a league management app.

    I currently have seasons, leagues and teams that are all working fine. I
    can create a new season, add the leagues that are playing in it and the
    teams that play within each of the leagues.

    What I now want to do is create fixtures for the teams. I have generated
    a fixtures model and associated it with teams (has_many :teams) and
    teams with fixtures (has_many :fixtures).

    What I would like to be able to do when a user sets up the fixtures he
    can just press a submit button that will generate all of the fixtures
    between the teams (each team plays the other twice). I have been able,
    using .permutations (get_team_combinations =
    Team.names.permutation(2).to_a) to generate an array of fixtures but I
    am stumped as
    to how it would be possible to have each of these entries in the array
    saved as a fixture in the database.
    well rather than permuting the names, i'd work with the teams
    directly, i.e.

    Team.all.permutation(2) do |team1, team2|
    Fixture.create(...)
    end

    and then in that block create the fixture object for team1 versus team
    2. Note that if you had teams a,b,c then you'll get both a,b and b,a
    as 2 different permutations. This might be what you want (e.g. if in a
    season each pair meets twice, swapping who is the home team and who is
    the away team), but if it isn't then try using combination instead of
    permutation

    Fred
    Anybody got any ideas how this is possible or an alternative way of
    generating the fixtures?
    Thanks for help in advance! :)

    --
    Posted viahttp://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 24, '11 at 11:35a
activeOct 24, '11 at 4:27p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Graham Dawe: 1 post Frederick Cheung: 1 post

People

Translate

site design / logo © 2021 Grokbase