安装Paperclip后不能db:migrate
can't db:migrate after installing Paperclip
我刚刚安装了 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'
为什么要尝试将图像添加到 posts
?我想你应该改变
add_attachment :posts, :image
至:
add_attachment :profiles, :image
我刚刚安装了 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'
为什么要尝试将图像添加到 posts
?我想你应该改变
add_attachment :posts, :image
至:
add_attachment :profiles, :image