Rake not able to migrate

前端 未结 2 460
别跟我提以往
别跟我提以往 2021-01-28 22:34
C:\\Users\\MEGHA\\bbbb>rake db:migrate
rake aborted!
SyntaxError: C:/Users/MEGHA/bbbb/db/migrate/20140402130040_create_comments.rb:4: syntax error, unexpected tIDENTI         


        
相关标签:
2条回答
  • 2021-01-28 23:33

    instead:

    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
    

    use

    class CreateComments < ActiveRecord::Migration
      def change
        create_table :comments do |t|
          t.integer :post_id
          t.text :body
    
          t.timestamps
        end
      end
    end
    
    0 讨论(0)
  • 2021-01-28 23:33

    In your migration you have used

    :post_id = integer

    Instead it needs to be as below:

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

    end

    0 讨论(0)
提交回复
热议问题