2014-04-02 121 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