我刚刚安装了Paperclip,我再也无法运行rake db:migrate。
迁移
class AddPaperclipToProfiles < ActiveRecord::Migration
def change
add_attachment :posts, :image
end
end
模型
class Profile < ActiveRecord::Base
has_attached_file :image, styles: { small: "64x64", med: "100x100", large: "200x200", xlarge: "300x300" }
end
这是错误
== 20151224145355 AddPaperclipToProfiles: migrating ===========================
-- add_attachment(:posts, :image)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: no such table: posts: ALTER TABLE "posts" ADD "image_file_name" varchar/Users/RichieSiegel/.rvm/gems/ruby-2.2.3/gems/sqlite3-1.3.11/lib/sqlite3/database.rb:91:in `initialize'
答案 0 :(得分:1)
您为什么要尝试将图片添加到posts
?我想你应该改变
add_attachment :posts, :image
为:
add_attachment :profiles, :image