Note that there are some explanatory texts on larger screens.

plurals
  1. POwhat is the proper syntax for seeding a database with an array?
    primarykey
    data
    text
    <p>I am a rails noob and I am trying to seed my database with an array and then a loop to fill assign the relevant code to the relevant variable. However, it isn't working. Please help.</p> <pre><code> Customer.delete_all b[0]=[1231215,'Jeremy', 'G', '9177477337', 'jt@gmail.com', 'Central Ave', 'Rockaway', 'NY', ' 12291', '76 Son Court', 'ft lauderdale','Florida', '32423', '1', '0', '1', '1', '1', '1', '0', '0', '1', '0', '9.95', 'Honda', '2012', 'Civic', '2.4 Turbo', 'Special', '1J474GFGDHDH8883334D0','fart monkey trap'] b[1]=[46545465,'Se', 'Wof', '521428788', 'steven.j.wolfman@gmail.com', '13 NE 17 Street', 'broward', 'FL', ' 32222', '13 NE 17 Street', 'boca','Florida', '32222', '0', '0', '1', '0', '0', '1', '1', '1', '1', '1', '19.95', 'Ford', '2012', 'Taurus', '4.0', 'Faster', '3458GDHD3YU34D0','it smells'] i=0 while i&lt;2 do Customer.create( :uid=&gt;b[i][0], :fname=&gt;b[i][1], :lname=&gt;b[i][2], :devphone=&gt; b[i][3], :email=&gt;b[i][4], :address=&gt;b[i][5], :city=&gt;b[i][6], :state=&gt;b[i][7], :zip=&gt;b[i][8], :baddress=&gt;b[i][9], :bcity=&gt;b[i][10], :bstate=&gt;b[i][11], :bzip=&gt;b[i][12], :roadass=&gt;b[i][13], :crisisass=&gt;b[i][14], :autocrash=&gt;b[i][15], :emergencyass=&gt;b[i][16], :remotediag=&gt;b[i][17], :carfind=&gt;b[i][18], :familytrack=&gt;b[i][19], :lowbatt=&gt;b[i][20], :towalerts=&gt;b[i][21], :monthlycost=&gt;b[i][22], :Make=&gt;b[i][23], :Year=&gt;b[i][24], :Model=&gt;b[i][25], :Engine=&gt;b[i][26], :VehicleSystem=&gt;b[i][27], :vinnum=&gt;b[i][28], :signupdate=&gt;b[i][29], :password=&gt;b[i][30], ) i+=1 end </code></pre> <p>This is the error I get when running db:seed: rake aborted! undefined local variable or method `b' for main:Object</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload