Just a note, you can restructure this to make it a little more DRY. I
find this easier to manage in the long run, particularly if I may need
to add more later.

buildingclasses = [
  {:name => "Name", :land_used => 1},
  {:name => "Name 2", :land_used => 2}
  // etc
]

puts "adding building classes"
buildingclasses.each do |b|
  BuildingClass.find_or_create_by_name(b)
end

Have you tried seeding with rails unfrozen? Wondering if you can
determine whether that's the problem, or if it's elsewhere.

On Oct 22, 9:33 am, Jamie <[email protected]> wrote:
> Hello All,
>
> I'm having trouble using the new rake db:seed function. I initially
> built my app in Rails 3.2.2 but have updated and re-frozen the new
> version (3.2.4) which is supposed to have the new data seeding
> function. I created a seed.rb file at db/seed.rb that looks something
> like this:
>
> BuildingClass.create(:name => "Residential Zones",    :land_used =>
> 1 )
> BuildingClass.create(:name => "Universities",         :land_used =>
> 2 )
> BuildingClass.create(:name => "Intelligence Centers", :land_used =>
> 3 )
> BuildingClass.create(:name => "Research Centers",     :land_used =>
> 2 )
> BuildingClass.create(:name => "Government Centers",   :land_used =>
> 2 )
> BuildingClass.create(:name => "Tank Factories",       :land_used =>
> 5 )
> BuildingClass.create(:name => "Plane Factories",      :land_used =>
> 5 )
> BuildingClass.create(:name => "Shipyards",            :land_used =>
> 5 )
> BuildingClass.create(:name => "Fortifications",       :land_used =>
> 2 )
>
> WeaponType.create(:weapon_branch_id => 1,   :offense_base =>
> 3.0,   :defense_base => 9.0,   :weapon_type_name =>
> "Tanks",         :description => "Defensive Ground Unit")
> WeaponType.create(:weapon_branch_id => 1,   :offense_base =>
> 12.0,  :defense_base => 3.0,   :weapon_type_name =>
> "Artillery",     :description => "Offensive Ground Unit")
> WeaponType.create(:weapon_branch_id => 2,   :offense_base =>
> 3.0,   :defense_base => 10.0,  :weapon_type_name =>
> "Fighters",      :description => "Defensive Air Unit")
>
> Whenever I try to run the command rake db:seed it appears to run with
> no errors but doesn't give any feedback and does not modify the DB.
>
> Is anybody able to help?
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to