【问题标题】:Whois gem not working in railsWhois gem 不能在 Rails 中工作
【发布时间】:2015-10-15 15:54:24
【问题描述】:
class DomaincheckerController < ApplicationController
  def index
  end
  def store
    r =Whois.whois(secure_params['domain'])
    render :text => "#{r}"
  end

  private
  def secure_params
    params.require(:whois).permit(:domain)
  end


end

这是我的域检查器控制器。 index 方法呈现一个表单。提交表单后,它转到 store 方法。在这里,我尝试使用 whois gem。我通过运行gem install whois 安装了whois gem。但是我收到了这个错误。

uninitialized constant DomaincheckerController::Whois 

【问题讨论】:

  • 这些情况下的标准问题:安装 gem 后是否重新启动了服务器?
  • @BroiSatse 是的,我也重启了 niginx 和 unicorn
  • 你是如何重启独角兽的? USR2?您需要进行硬重启。无需重启 nginx。
  • @BroiSatse,我以为我重新启动了独角兽。我做了 service unicorn_fuitter stop 然后跑了 service unicorn_fuitter start 。但即使我这样做了service unicorn_fuitter stop,我的应用程序仍在运行。
  • 您的 etc 脚本可能不正确。尝试使用kill --QUIT手动重启它

标签: ruby-on-rails ruby whois whois-ruby


【解决方案1】:

问题是您直接安装了 gem 而不是使用bundler,因此 Rails 应用找不到依赖项。

为了在 Rails 项目中安装 gem,您需要编辑 Gemfile 文件并在其中添加 gem。添加后,运行

$ bundle

为了安装依赖。检查documentation about the Gemfile

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-07
    • 2017-04-10
    • 1970-01-01
    • 2018-02-18
    • 2019-12-08
    相关资源
    最近更新 更多