我在通过paperclip gem安装图片附件后尝试运行db:migrate,它不允许我进行迁移。有人可以帮忙吗?非常感谢This is what it said on my terminal
这是我的配置文件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 :(得分:1)
您正在向不存在的数据库添加列。你没有items
表,你的todo_items
表你的迁移应该是这样的:
$ bin/rails generate migration AddAttachmentImageToTodoItems attachment_image:string