Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails `要求';:无法加载这样的文件--rest\u客户端(LoadError)_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails `要求';:无法加载这样的文件--rest\u客户端(LoadError)

Ruby on rails `要求';:无法加载这样的文件--rest\u客户端(LoadError),ruby-on-rails,ruby,Ruby On Rails,Ruby,我正在构建第一个gems,我想使用rest\u客户端gems作为我的gems,我已经在lib/foo/Gemfile上放置了gem'rest\u客户端',“~>1.8.3',这是我的文件 # lib/foo/lib/foo.rb require 'rest_client' require 'json' require "foo/version" module Foo # other stuff here end 当我运行rails c时,出现以下错误: /home/user/.rvm/g

我正在构建第一个gems,我想使用rest\u客户端gems作为我的gems,我已经在
lib/foo/Gemfile
上放置了
gem'rest\u客户端',“~>1.8.3'
,这是我的文件

# lib/foo/lib/foo.rb

require 'rest_client'
require 'json'
require "foo/version"

module Foo
 # other stuff here
end
当我运行
rails c
时,出现以下错误:

/home/user/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- rest_client (LoadError)

注意:我已经在rails应用程序中安装了我的gems

我认为您需要尝试
要求“rest客户端”
尝试下面的内容-

require 'rest-client'

谢谢,但是我正在使用这个,我应该使用
require'rest\u client'
,而且在我问这个问题之前我已经试过了。有趣的是,我刚刚安装了gem,用ruby 2.2.2进行了尝试<代码>要求rest客户端已工作,但返回了一条折旧消息:
警告:rest\u客户端gem已弃用,将从RubyGems中删除。请改用rest客户端gem。
如果您正在构建gem,则应在GEMPEC文件中声明此依赖项。这里有一个关于这个问题的很好的教程。而且
gems
rails
是非常不同的东西
rails
用于构建web应用程序并使用gems,而gem是一个插件库。@engineersmnky谢谢,我忘了添加依赖项。。