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?
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
<james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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?
Yeah, I thought of combining them into something like you suggested, but wanted to get them working in the simplest form before I tried complicating the file. I''ll try running it with an unfrozen rails later tonight. Don''t have access to an updated rails install right now...thus the frozen rails :) On Oct 22, 1:00 pm, sax <s...-c5KP9hz/kbxwMgcQ4+lbG0B+6BGkLq7r@public.gmane.org> wrote:> 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 <james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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?
Tried it with an unfrozen rails install....still won''t work. I also
stripped most of the seed data out of the file and condensed the
information for the one model I left in. This is the file in it''s
entirety:
buildingclasses = [
{:name => "Commercial Zones", :land_used => 1 },
{:name => "Residential Zones", :land_used => 1},
{:name => "Universities", :land_used => 2 },
{:name => "Intelligence Centers", :land_used => 3 },
{:name => "Research Centers", :land_used => 2 },
{:name => "Government Centers", :land_used => 2 },
{:name => "Tank Factories", :land_used => 5 },
{:name => "Plane Factories", :land_used => 5 },
{:name => "Shipyards", :land_used => 5 },
{:name => "Fortifications", :land_used => 2 }
]
puts "adding building classes"
buildingclasses.each do |b|
BuildingClass.find_or_create_by_name(b)
end
On Oct 22, 1:27 pm, Jamie
<james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Yeah, I thought of combining them into something like you suggested,
> but wanted to get them working in the simplest form before I tried
> complicating the file.
>
> I''ll try running it with an unfrozen rails later tonight.
Don''t have
> access to an updated rails install right now...thus the frozen
> rails :)
>
> On Oct 22, 1:00 pm, sax
<s...-c5KP9hz/kbxwMgcQ4+lbG0B+6BGkLq7r@public.gmane.org> wrote:
>
>
>
> > 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
<james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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?
well...i feel like an idiot...the blog that I googled and found the instructions for using this on said to use db/seed.rb. just changed it to seeds.rb and it worked beautifully. On Oct 22, 7:43 pm, Jamie <james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Tried it with an unfrozen rails install....still won''t work. I also > stripped most of the seed data out of the file and condensed the > information for the one model I left in. This is the file in it''s > entirety: > > buildingclasses = [ > {:name => "Commercial Zones", :land_used => 1 }, > {:name => "Residential Zones", :land_used => 1}, > {:name => "Universities", :land_used => 2 }, > {:name => "Intelligence Centers", :land_used => 3 }, > {:name => "Research Centers", :land_used => 2 }, > {:name => "Government Centers", :land_used => 2 }, > {:name => "Tank Factories", :land_used => 5 }, > {:name => "Plane Factories", :land_used => 5 }, > {:name => "Shipyards", :land_used => 5 }, > {:name => "Fortifications", :land_used => 2 } > ] > > puts "adding building classes" > buildingclasses.each do |b| > BuildingClass.find_or_create_by_name(b) > end > > On Oct 22, 1:27 pm, Jamie <james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Yeah, I thought of combining them into something like you suggested, > > but wanted to get them working in the simplest form before I tried > > complicating the file. > > > I''ll try running it with an unfrozen rails later tonight. Don''t have > > access to an updated rails install right now...thus the frozen > > rails :) > > > On Oct 22, 1:00 pm, sax <s...-c5KP9hz/kbxwMgcQ4+lbG0B+6BGkLq7r@public.gmane.org> wrote: > > > > 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 <james.white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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?