没有这样的文件加载——RMagick.Rails, Ubuntu



我使用rvm在我的主目录中安装了ruby和我的gems。'require RMagick'从控制台和irb中工作,但不是从我的Rails应用程序中。我在我的Gemfile中列出了gem。

require 'RMagick'
class PetsController < ApplicationController
  def image
    image = Image.new(image_path("base/Base.png"))
    #image = Pet.composite(0, '4a4a4a')
    @response.headers["Content-type"] = image.mime_type
    render :text => image.to_blob
  end
end 

如果我从控制器中移除require,我得到

uninitialized constant PetsController::Image

我也尝试过启动require 'RMagick'。通过使用Magick::Image(这给了我uninitialized constant PetsController::Magick)引用图像对象。

我做错了什么?

解决了!重新启动服务器修复了这个问题。我猜我没有重新启动服务器时,我添加了rmagick到我的gemfile.

是否有可能您正在与另一个用户运行rails应用程序而不是安装了RMagick gem的用户?

最新更新