简体   繁体   English

在Ruby on Rails中使用gem似乎不起作用

[英]Using a gem in Ruby on Rails does not seem to work

I have installed the gem ruby-imagespec 我已经安装了gem ruby-imagespec

The code looks like the following: 该代码如下所示:

class TestController < ApplicationController
  def ratio(fid)
    file = File.new("#{Rails.public_path}/test/#{fid}.swf", "rb")
    dimensions = ImageSpec.new(file)
    return dimensions
  end
  helper_method :ratio
end

When I try to run this I get an error: 当我尝试运行此命令时,出现错误:

"uninitialized constant TestController::ImageSpec" on line 7 The gem is listed in the gemfile and explicitly requiring it does not work. 第7行上的“未初始化的常量TestController :: ImageSpec” gem在gemfile中列出,明确要求它不起作用。

Where is the error? 错误在哪里? The gem is installed correctly and this code is just like the code from the gem's README gem已正确安装,此代码与gem的README中的代码一样

ruby-imagespec is an unsupported gem, please try fastimage: ruby-imagespec是不受支持的gem,请尝试使用fastimage:

add gem 'fastimage' in your Gemfile 在您的Gemfile中添加gem 'fastimage'

here the documentation https://github.com/sdsykes/fastimage 这里是文档https://github.com/sdsykes/fastimage

Looking at the ruby-imagespec repository , the file you need to require appears to be lib/image_spec.rb. 查看ruby-imagespec存储库 ,您需要的文件似乎是lib / image_spec.rb。 Try require 'image_spec' . 尝试require 'image_spec'

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

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