簡體   English   中英

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

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

我已經安裝了gem ruby-imagespec

該代碼如下所示:

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

當我嘗試運行此命令時,出現錯誤:

第7行上的“未初始化的常量TestController :: ImageSpec” gem在gemfile中列出,明確要求它不起作用。

錯誤在哪里? gem已正確安裝,此代碼與gem的README中的代碼一樣

ruby-imagespec是不受支持的gem,請嘗試使用fastimage:

在您的Gemfile中添加gem 'fastimage'

這里是文檔https://github.com/sdsykes/fastimage

查看ruby-imagespec存儲庫 ,您需要的文件似乎是lib / image_spec.rb。 嘗試require 'image_spec'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM