gpt4 book ai didi

ruby-on-rails - ruby 错误 : cannot load such file -- rest-client

转载 作者:数据小太阳 更新时间:2023-10-29 06:34:24 25 4
gpt4 key购买 nike

我正在使用 Ruby on Rails 4。

我正在努力

require 'rest-client'

在我的 Controller 中,以便我可以解析从表单中获取的登录信息并将其发送到 API。

我可以验证 gem 是否已安装并且也在我的应用程序根目录下的 Gemfile 中。

但是,当我尝试在我的 Controller 中请求该文件时,它仍然抛出“无法加载此类文件 -- rest-client”。

我用谷歌搜索了这个错误,我看到的大部分答案要么是 gem 没有安装,要么不在 Gemfile 中,要么是两者兼而有之。这里的情况也不是。

我的 Controller 是否由于某种原因无法访问 rest-client gem?我必须使用 rest-client,因为它在 API 中是必需的。

这是我用来安装 gem 的行:

gem install rest-client

这是 gem 的主页:https://github.com/archiloque/rest-client
这只是将您重定向到 https://github.com/rest-client/rest-client

我还应该注意到,当我没有在 Rails 项目中使用代码而只是在终端中运行命令时,它工作正常。

最佳答案

假设您使用的是 https://github.com/rest-client/rest-client (因为你没有指定),你的 require 行应该是

require 'rest-client'

根据README .此外,请确保在将 gem 添加到 Gemfile 并运行 bundle 后重新启动 Rails 服务器。

关于ruby-on-rails - ruby 错误 : cannot load such file -- rest-client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17973872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com