Sha256: 60fc0799113832f3d20fb784eaf442c0e57c6ce17ee72356d47b64985b43a3e0

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'mlb'

User.create(:email => 'username@example.com', :password => 'password', :password_confirmation => 'password')

MLB::Team.all.each do |mlb_team|
  unless league = League.first(:conditions => ["name = ?", mlb_team.league])
    league = League.create(:name => mlb_team.league)
  end
  unless division = Division.first(:conditions => ["name = ?", mlb_team.division])
    division = Division.create(:name => mlb_team.division, :league => league)
  end
  unless team = Team.first(:conditions => ["name = ?", mlb_team.name])
    team = Team.create(:name => mlb_team.name, :logo_url => mlb_team.logo_url, :manager => mlb_team.manager, :ballpark => mlb_team.ballpark, :mascot => mlb_team.mascot, :founded => mlb_team.founded, :wins => mlb_team.wins, :losses => mlb_team.losses, :win_percentage => ("%.3f" % (mlb_team.wins.to_f / (mlb_team.wins + mlb_team.losses))).to_f, :division => division)
  end
  mlb_team.players.reject{|player| player.number.nil?}.each do |player|
    Player.create(:name => player.name, :number => player.number, :position => player.position, :team => team)
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
obitum-rails_admin-0.0.5 spec/dummy_app/db/seeds.rb
drewda_rails_admin-0.0.1 spec/dummy_app/db/seeds.rb
obitum-rails_admin-0.0.4 spec/dummy_app/db/seeds.rb