简体   繁体   English

耙db:迁移错误-回形针

[英]Rake db:migrate error - paperclip

I have installed Paperclip but I have error when I try to run 我已经安装了回形针,但是尝试运行时出现错误

rake db:migrate

after

rails generate paperclip asset photo

I get 我懂了

cannot load such file -- paperclip/tasks/attachments 无法加载此类文件-回形针/任务/附件

What is wrong? 怎么了? This folder exists with that file. 该文件夹与该文件一起存在。

尝试使用:

bundle exec rake db:migrate

When I tried downloading it as a plugin (rails plugin install ... ), I saw the same problem. 当我尝试将其下载为插件(rails plugin install ...)时,我遇到了同样的问题。 I deleted the plugins from vendor/plugins directory and then added the paperclip gem to gemfile ( gem "paperclip", "~> 3.0" ) and everything now works. 我从vendor / plugins目录中删除了插件,然后将回形针gem添加到了gemfile中( gem "paperclip", "~> 3.0" paperclip gem "paperclip", "~> 3.0" ),现在一切正常。 You may want to give it a try. 您可能需要尝试一下。

To make sure paperclip is loaded and the version which supports attachments, do 要确保已加载回形针和支持附件的版本,请执行

bundle show paperclip

Open the gem in text editor and check if paperclip/tasks/attachments.rb is present. 在文本编辑器中打开gem,并检查是否存在paperclip / tasks / attachments.rb。 If no, then the version of the gem needs to be upgraded or uninstall all paperclip gem versions and do a fresh install. 如果否,则需要升级gem版本或卸载所有回形针gem版本并重新安装。 paperclip-3.5.0 works. 回形针3.5.0的作品。

If the version is correct and if it still throws error, include 如果版本正确并且仍然抛出错误,请包括

require 'paperclip'

in your boot.rb. 在您的boot.rb中。

This forces rails to include the gem at boot time. 这会在启动时强制铁轨包括宝石。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM