# Forum: Rails-ES Problema para asignar un array a un modelo

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
on 2009-05-05 20:20
```He tenido que implementar un algoritmo Round-Robin para crear el
calendario de jornadas de mi aplicaciÃ³n (el algoritmo es correcto), pero
tengo problemas para asignar los resultados a mis modelos, pego aquÃ­ el
cÃ³digo:

def create_rounds
rounds = make_rounds(self.clubs)
self.rounds = rounds
end

def make_rounds(clubs)
#If odd insert dummy club
if clubs.length % 2 == 1
clubs << :dummy
end

rounds_home = []
rounds_away = []
num_rounds = clubs.length - 1
num_matches = clubs.length / 2 - 1

for i in (1..num_rounds)
matches_home = []
matches_away = []
for j in (0..num_matches)
matches_home << MatchGeneral.new({
:local => clubs[j],
:guest => clubs[num_rounds - j]
}) #Home match
matches_away << MatchGeneral.new({
:local => clubs[num_rounds - j],
:guest => clubs[j]
})
end
rounds_home << Round.new({
:round_number => i,
:match_generals => matches_home
})
rounds_away << Round.new({
:round_number => num_rounds +  i,
:match_generals => matches_away})
#rotating the teams
last = clubs.pop
clubs.insert(1, last)
end

rounds_away.each { |x| rounds_home << x}
return rounds_home
end

El error que recibo al ejecutar el mÃ©todo create_rounds es este:

undefined method `local_before_type_cast' for #<MatchGeneral:0xb71d0a08>

Â¿QuÃ© estoy haciendo mal?```
on 2009-05-05 20:54
```SÃ© que el problema estÃ¡ en los match_general ya que si asigno el vector
sin haber rellenado los match_generals funciona perfectamente Â¿A quÃ© es
debido esto?```
This topic is locked and can not be replied to.