2014-04-02 124 views
0
C:\Users\MEGHA\bbbb>rake db:migrate 
rake aborted! 
SyntaxError: C:/Users/MEGHA/bbbb/db/migrate/20140402130040_create_comments.rb:4: syntax error, unexpected tIDENTIFIER, expecting keyword_end 
C:65535:in `disable_ddl_transaction' 
Tasks: TOP => db:migrate 
(See full trace by running task with --trace) 

20140402130040_create_comments.rb耙无法迁移

class CreateComments < ActiveRecord::Migration 
    def change 
    create_table :comments do |t| 
     t.string :post_id=integer 
     t.text :body 

     t.timestamps 
    end 
    end 
end 
+0

的[NOT能够耙分贝可能重复:迁移(http://stackoverflow.com/questions/22806780/not-able-to-rake-dbmigrate)。提问者,我已经投票决定将此问题作为您接受答案的副本的复本。将来,请避免多次发布相同的问题。 –

回答

1

代替:

class CreateComments < ActiveRecord::Migration 
    def change 
    create_table :comments do |t| 
     t.string :post_id=integer #<= this 
     t.text :body 

     t.timestamps 
    end 
    end 
end 

使用

class CreateComments < ActiveRecord::Migration 
    def change 
    create_table :comments do |t| 
     t.integer :post_id 
     t.text :body 

     t.timestamps 
    end 
    end 
end 
0

在你迁移你已经使用

:POST_ID =整数

相反,它必须是如下:

class CreateComments < ActiveRecord::Migration 
    def change 
create_table :comments do |t| 
    t.integer :post_id 
    t.text :body 
    t.timestamps 
    end 
end