ruby-on-rails - rails 在生产服务器中包含 CarrierWave::RMagick 错误

标签 ruby-on-rails ruby carrierwave rmagick

我想使用带有载波的 rmagick gem 来上传和调整图像大小。

在我的 Local Rails 中..它运行良好。 但是当部署到服务器时.. 不起作用..

不知道为什么T^T

这里是 unicorn_error_log..

.../shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': No such file to load -- RMagick (LoadError)
from .../shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from .../shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from .../shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from .../shared/bundle/ruby/2.0.0/gems/carrierwave-0.9.0/lib/carrierwave/processing/rmagick.rb:67:in `rescue in block in <module:RMagick>'
from ...p/shared/bundle/ruby/2.0.0/gems/carrierwave-0.9.0/lib/carrierwave/processing/rmagick.rb:64:in `block in <module:RMagick>'
from .../shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/concern.rb:114:in `class_eval'
from .../shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/concern.rb:114:in `append_features'
from .../releases/20131018192701/app/uploaders/image_uploader.rb:5:in `include'
from .../releases/20131018192701/app/uploaders/image_uploader.rb:5:in `<class:ImageUploader>'
from .../releases/20131018192701/app/uploaders/image_uploader.rb:3:in `<top (required)>'

但奇怪的是在 server rails c 生产中

a = Word.find(2)
a.image.recreate_versions!(:image, :thumb)

这很好用,没有错误!!! thumb_~~.jpg ,生成调整大小的图像..

并在 server rails c 生产输入中

require 'RMagick'
=> false

这意味着 RMagick 已经在加载了,对吧?

啊!这是我的 image_uploader.rb

3: class ImageUploader < CarrierWave::Uploader::Base

5:    include CarrierWave::RMagick

52:   version :thumb do
53:      process :resize_to_limit => [400, 400]
54:   end

第 5 行错误!

作为引用,我已经在下面完成了..

apt-get install libmagickwand-dev imagemagick
in Gemfile |  gem 'rmagick', :require => 'RMagick'

请帮帮我.. 为什么不在服务器上工作??

最佳答案

你是如何运行服务器的?

如果你的 Gemfile 有 rmagick 那么你需要使用 bundle exec 运行服务器

有时没有加载依赖项。 bundle exec 将确保始终加载依赖项。

关于ruby-on-rails - rails 在生产服务器中包含 CarrierWave::RMagick 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19457965/

相关文章:

ruby-on-rails - 统计分析 Rails 应用程序的最佳托管

ruby-on-rails - 无法连接到本地 PostgreSQL

ruby-on-rails - 如何在本地生成签名的 Stripe rest webhook 请求?

ruby - Logstash过滤出嵌套json数组中的键的值为空的值

javascript - react rails : Map multiple props

ruby-on-rails - 载波与 DigitalOcean 集成

ruby-on-rails - Carrierwave - 如果文件类型不在白名单上,则触发存在验证

ruby-on-rails - 使用 OpenSSL 读取证书文件时出现 Ruby 错误

ruby - Gem 安装错误 : You have to install development tools first (Windows)

ruby-on-rails - 使用 Carrierwave 从 Rails 控制台上传远程文件 url