2016-11-14 112 views
-2

我試圖運行db:通過回形針gem安裝圖像附件後遷移,它不會允許我執行遷移。有人可以幫忙嗎?非常感謝This is what it said on my terminal無法運行db:在Rails中遷移

這是我的配置文件config/database.yml

這是我創建項目表:

class CreateTodoItems < ActiveRecord::Migration[5.0] 
    def change 
    create_table :todo_items do |t| 
     t.column :content 
     t.column :deadline 

     t.references :todo_list, foreign_key: true 

     t.timestamps 
    end 
    end 
end 

項目模型

class TodoItem < ActiveRecord::Base 

    belongs_to :todo_list 

    has_attached_file :image, styles: { medium: "500x500>", thumb: "100x100#"} 

    validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/ 

    def completed? 

    !completed_at.blank? 

    end 

end 
+0

請發表你的config/database.yml文件 – jaysoifer

+0

默認:默認 適配器:sqlite3的 池:5 超時:5000 發展: <<:*默認 數據庫:DB/development.sqlite3 #警告:定義爲 「測試」 數據庫將被刪除,從開發DAT #重新生成當你運行「耙」時放棄。 #不要將此數據庫設置爲與開發或生產相同。 測試: <<:*默認 數據庫:DB/test.sqlite3 生產: <<:*默認 數據庫:DB/production.sqlite3 –

+0

@jaysoifer:默認:默認 適配器:sqlite3的 池:5 超時:5000 發展: <<:*默認 數據庫:DB/development.sqlite3 測試: <<:*默認 數據庫:DB/test.sqlite3 生產: <<:*默認 數據庫:db/production.sqlite3 –

回答

1

你添加一列到數據庫不存在。你不碰巧有items表已todo_items表遷移應該是這個樣子:

$ bin/rails generate migration AddAttachmentImageToTodoItems attachment_image:string

相關問題