Forum: Ruby on Rails Newbee rake migrate question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lee H. (Guest)
on 2006-04-20 10:20
(Received via mailing list)
with a simple table def.

class Objects < ActiveRecord::Migration
  def self.up
      create_table :objects do |table|
        table.column :name, string
  end

  def self.down
      drop_table :objects
  end
end


when I run rake migrate, I get:

** Invoke migrate (first_time)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
./db/migrate//001_objects.rb:10: parse error, unexpected $, expecting
kEND
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in
`load'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in
`load'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:340:in
`migration_classes'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:190:in
`inject'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:339:in
`migration_classes'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:327:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:294:in
`up'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:285:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/tasks/databases.rake:4
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'
/usr/local/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:in
`invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in
`invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in `invoke'
/usr/local/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/local/bin/rake:18

from terminal

and

  SQL (0.031305)   CREATE TABLE schema_info
(version int(11))
  SQL (0.004014)   INSERT INTO schema_info (version)
VALUES(0)
  SQL (0.000000)   Mysql::Error: Table
'schema_info' already exists: CREATE TABLE schema_info (version
int(11))
  SQL (0.000000)   Mysql::Error: Table
'schema_info' already exists: CREATE TABLE schema_info (version
int(11))
  SQL (0.000000)   Mysql::Error: Table 'schema_info'
already exists: CREATE TABLE schema_info (version int(11))

in the log.

(of course schema_info didn't exist until I ran rake.)

I've googled this quite a bit and see people talking about ruby 1.8.4
breaking things, but I don't find a specific comment about the model
making.

Any directions?

Thanks, in advance.
David (Guest)
on 2006-04-20 11:18
Lee H. wrote:
> with a simple table def.
>
> class Objects < ActiveRecord::Migration
>   def self.up
>       create_table :objects do |table|
>         table.column :name, string
>   end

I think your problem is here, you haven't ended the "do" block.

Add another end, after you add the column.

David
Lee H. (Guest)
on 2006-04-20 17:39
(Received via mailing list)
On 4/20/06, David <removed_email_address@domain.invalid> wrote:
>
> Add another end, after you add the column.
>
> David

Thank you. That got me further and I'll look around before I ask about
the next error message.

--
Tech support: Click on the 'my computer' icon on to the left of the
screen.
Customer: Your left or my left?
Lee H. (Guest)
on 2006-04-20 17:42
(Received via mailing list)
On 4/20/06, Lee H. <removed_email_address@domain.invalid> wrote:
> > I think your problem is here, you haven't ended the "do" block.
> >
> > Add another end, after you add the column.
> >
> > David
>
> Thank you. That got me further and I'll look around before I ask about
> the next error message.

A missing colon, and I'm good to go.

Thanks again.

--
Tech support: Click on the 'my computer' icon on to the left of the
screen.
Customer: Your left or my left?
Jean-François (Guest)
on 2006-04-21 00:41
(Received via mailing list)
Lee :
> > > > class Objects < ActiveRecord::Migration
> > > >   def self.up
> > > >       create_table :objects do |table|
> > > >         table.column :name, string
> > > >   end

> > Thank you. That got me further and I'll look around before
> > I ask about the next error message.

Be careful, Object is a reserved word.

http://ruby-doc.org/core/classes/Object.html

   -- Jean-François.
This topic is locked and can not be replied to.