Rake db:migrate - error 'tSYMBEG'


#1

I’m going through the ‘Depot’ project in “Agile Web D. with
Rails”. I just made the 003_add_test_data.rb file and when I do a “rake
db:migrate”, I get this error and I can’t figure out what is wrong:

rake aborted!
./db/migrate//003_add_test_data.rb:5: parse error, unexpected tSYMBEG
5. :description =>

(and the ‘d’ in description has a little arrow below it pointing up)


#2

Josh Josh wrote:

rake aborted!
./db/migrate//003_add_test_data.rb:5: parse error, unexpected tSYMBEG
5. :description =>

(and the ‘d’ in description has a little arrow below it pointing up)

Welcome to how Ruby displays syntax errors. The language is so
flexible that it provides confusing diagnostics. This is why I compile
and test after only a few edits.

Post your whole file. Something on the line before this one left the
parser not expecting a symbol.


Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!


#3

Phlip wrote:

Josh Josh wrote:

rake aborted!
./db/migrate//003_add_test_data.rb:5: parse error, unexpected tSYMBEG
5. :description =>

(and the ‘d’ in description has a little arrow below it pointing up)

Welcome to how Ruby displays syntax errors. The language is so
flexible that it provides confusing diagnostics. This is why I compile
and test after only a few edits.

Post your whole file. Something on the line before this one left the
parser not expecting a symbol.


Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!

Ok, here’s the whole file:

class AddTestData < ActiveRecord::Migration
   2.   def self.up
   3.     products = []
   4.     products << {:title => 'Pragmatic Project Automation',
   5.       :description =>
   6.     %{<p>
   7.        <em>Pragmatic Project Automation</em> shows you how to 
improve the
   8.        consistency and repeatability of your project's procedures 
using
   9.        automation to reduce risk and errors.
  10.       </p>
  11.       <p>
  12.         Simply put, we're going to put this thing called a 
computer to work
  13.         for you doing the mundane (but important) project stuff. 
That means
  14.         you'll have more time and energy to do the really
  15.         exciting---and difficult---stuff, like writing quality 
code.
  16.       </p>},
  17.       :image_url =>   '/images/auto.jpg',
  18.       :price => 29.95 }
  19.
  20.     products << {:title => 'Pragmatic Version Control',
  21.       :description =>
  22.       %{<p>
  23.          This book is a recipe-based approach to using Subversion 
that will
  24.          get you up and running quickly---and correctly. All 
projects need
  25.          version control: it's a foundational piece of any 
project's
  26.          infrastructure. Yet half of all project teams in the U.S. 
don't use
  27.          any version control at all. Many others don't use it 
well, and end
  28.          up experiencing time-consuming problems.
  29.       </p>},
  30.       :image_url => '/images/svn.jpg',
  31.       :price => 28.50}
  32.
  33.     products << {:title => 'Pragmatic Unit Testing (C#)',
  34.       :description =>
  35.       %{<p>
  36.         Pragmatic programmers use feedback to drive their 
development and
  37.         personal processes. The most valuable feedback you can get 
while
  38.         coding comes from unit testing.
  39.       </p>
  40.       <p>
  41.         Without good tests in place, coding can become a 
frustrating game of
  42.         "whack-a-mole." That's the carnival game where the player 
strikes at a
  43.         mechanical mole; it retreats and another mole pops up on 
the opposite side
  44.         of the field. The moles pop up and down so fast that you 
end up flailing
  45.         your mallet helplessly as the moles continue to pop up 
where you least
  46.         expect them.
  47.       </p>},
  48.       :image_url => '/images/utc.jpg',
  49.       :price => 27.75}
  50.     products.each do |p|
  51.       product = Product.create(p)
  52.       raise product.errors.inspect unless product.valid?
  53.     end
  54.   end
  55.
  56.   def self.down
  57.     Product.delete_all
  58.   end
  59. end

#4

Ok… I’m an idiot. When I had copied code from somewhere, it copied in
the line numbers, and it looked normal to me, but it wasn’t in my editor
obviously.


#5

You might have successfully migrated up as far as you can. When you’re
all
migrated up, rake db:migrate does that.

RSL


#6

Now that I’m not getting that error, the “rake db:migrate” command
doesn’t seem to do anything at all… Nothing is input into the
database at all. Here is what I get when I type in “rake db:migrate”

(in C:/InstantRails/rails_apps/work/depot)

And then it returns me to the command prompt. Any idea why it isn’t
doing anything at all?